<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<title>API: loader   loader.js  (YUI Library)</title>

	<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
	<link rel="stylesheet" type="text/css" href="assets/api.css" />

    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">
	<div id="hd">
        <h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
        <h3>loader&nbsp; <span class="subtitle">3.3.0</span></h3>
        <a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a> 
            &gt; <a href="./module_loader.html" title="loader">loader</a>
                
                 &gt; loader.js (source view) 
        <form onsubmit="return false">
            <div id="propertysearch">
                Search: <input autocomplete="off" id="searchinput" />
                <div id="searchresults">
                    &nbsp;
                </div>
            </div>
        </form>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
                <fieldset>
                    <legend>Filters</legend>
                <span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
                <span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
                <span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
                </fieldset>
            </form>

                    <div id="srcout">
                        <style>
                            #doc3 .classopts { display:none; }
                        </style>
                        <div class="highlight"><pre><span class="cm">/**</span>
<span class="cm"> * Loader dynamically loads script and css files.  It includes the dependency</span>
<span class="cm"> * info for the version of the library in use, and will automatically pull in</span>
<span class="cm"> * dependencies for the modules requested.  It supports rollup files and will</span>
<span class="cm"> * automatically use these when appropriate in order to minimize the number of</span>
<span class="cm"> * http connections required to load all of the dependencies.  It can load the</span>
<span class="cm"> * files from the Yahoo! CDN, and it can utilize the combo service provided on</span>
<span class="cm"> * this network to reduce the number of http connections required to download</span>
<span class="cm"> * YUI files.</span>
<span class="cm"> *</span>
<span class="cm"> * @module loader</span>
<span class="cm"> * @submodule loader-base</span>
<span class="cm"> */</span>

<span class="kd">var</span> <span class="nx">NOT_FOUND</span> <span class="o">=</span> <span class="p">{},</span>
    <span class="nx">NO_REQUIREMENTS</span> <span class="o">=</span> <span class="p">[],</span>
    <span class="nx">MAX_URL_LENGTH</span> <span class="o">=</span> <span class="p">(</span><span class="nx">Y</span><span class="p">.</span><span class="nx">UA</span><span class="p">.</span><span class="nx">ie</span><span class="p">)</span> <span class="o">?</span> <span class="mi">2048</span> <span class="o">:</span> <span class="mi">8192</span><span class="p">,</span>
    <span class="nx">GLOBAL_ENV</span> <span class="o">=</span> <span class="nx">YUI</span><span class="p">.</span><span class="nx">Env</span><span class="p">,</span>
    <span class="nx">GLOBAL_LOADED</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_loaded</span><span class="p">,</span>
    <span class="nx">CSS</span> <span class="o">=</span> <span class="s1">&#39;css&#39;</span><span class="p">,</span>
    <span class="nx">JS</span> <span class="o">=</span> <span class="s1">&#39;js&#39;</span><span class="p">,</span>
    <span class="nx">INTL</span> <span class="o">=</span> <span class="s1">&#39;intl&#39;</span><span class="p">,</span>
    <span class="nx">VERSION</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">version</span><span class="p">,</span>
    <span class="nx">ROOT_LANG</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
    <span class="nx">YObject</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nb">Object</span><span class="p">,</span>
    <span class="nx">oeach</span> <span class="o">=</span> <span class="nx">YObject</span><span class="p">.</span><span class="nx">each</span><span class="p">,</span>
    <span class="nx">YArray</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nb">Array</span><span class="p">,</span>
    <span class="nx">_queue</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_loaderQueue</span><span class="p">,</span>
    <span class="nx">META</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">[</span><span class="nx">VERSION</span><span class="p">],</span>
    <span class="nx">SKIN_PREFIX</span> <span class="o">=</span> <span class="s1">&#39;skin-&#39;</span><span class="p">,</span>
    <span class="nx">L</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Lang</span><span class="p">,</span>
    <span class="nx">ON_PAGE</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">mods</span><span class="p">,</span>
    <span class="nx">modulekey</span><span class="p">,</span>
    <span class="nx">cache</span><span class="p">,</span>
    <span class="nx">_path</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">dir</span><span class="p">,</span> <span class="nx">file</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">nomin</span><span class="p">)</span> <span class="p">{</span>
                        <span class="kd">var</span> <span class="nx">path</span> <span class="o">=</span> <span class="nx">dir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">file</span><span class="p">;</span>
                        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">nomin</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">path</span> <span class="o">+=</span> <span class="s1">&#39;-min&#39;</span><span class="p">;</span>
                        <span class="p">}</span>
                        <span class="nx">path</span> <span class="o">+=</span> <span class="s1">&#39;.&#39;</span> <span class="o">+</span> <span class="p">(</span><span class="nx">type</span> <span class="o">||</span> <span class="nx">CSS</span><span class="p">);</span>

                        <span class="k">return</span> <span class="nx">path</span><span class="p">;</span>
                    <span class="p">};</span>

<span class="cm">/**</span>
<span class="cm"> * The component metadata is stored in Y.Env.meta.</span>
<span class="cm"> * Part of the loader module.</span>
<span class="cm"> * @property Env.meta</span>
<span class="cm"> * @for YUI</span>
<span class="cm"> */</span>
<span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span> <span class="o">=</span> <span class="nx">META</span><span class="p">;</span>

<span class="cm">/**</span>
<span class="cm"> * Loader dynamically loads script and css files.  It includes the dependency</span>
<span class="cm"> * info for the version of the library in use, and will automatically pull in</span>
<span class="cm"> * dependencies for the modules requested.  It supports rollup files and will</span>
<span class="cm"> * automatically use these when appropriate in order to minimize the number of</span>
<span class="cm"> * http connections required to load all of the dependencies.  It can load the</span>
<span class="cm"> * files from the Yahoo! CDN, and it can utilize the combo service provided on</span>
<span class="cm"> * this network to reduce the number of http connections required to download</span>
<span class="cm"> * YUI files.</span>
<span class="cm"> *</span>
<span class="cm"> * While the loader can be instantiated by the end user, it normally is not.</span>
<span class="cm"> * @see YUI.use for the normal use case.  The use function automatically will</span>
<span class="cm"> * pull in missing dependencies.</span>
<span class="cm"> *</span>
<span class="cm"> * @constructor</span>
<span class="cm"> * @class Loader</span>
<span class="cm"> * @param {object} o an optional set of configuration options.  Valid options:</span>
<span class="cm"> * &lt;ul&gt;</span>
<span class="cm"> *  &lt;li&gt;base:</span>
<span class="cm"> *  The base dir&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;comboBase:</span>
<span class="cm"> *  The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;root:</span>
<span class="cm"> *  The root path to prepend to module names for the combo service.</span>
<span class="cm"> *  Ex: 2.5.2/build/&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;filter:.</span>
<span class="cm"> *</span>
<span class="cm"> * A filter to apply to result urls.  This filter will modify the default</span>
<span class="cm"> * path for all modules.  The default path for the YUI library is the</span>
<span class="cm"> * minified version of the files (e.g., event-min.js).  The filter property</span>
<span class="cm"> * can be a predefined filter or a custom filter.  The valid predefined</span>
<span class="cm"> * filters are:</span>
<span class="cm"> * &lt;dl&gt;</span>
<span class="cm"> *  &lt;dt&gt;DEBUG&lt;/dt&gt;</span>
<span class="cm"> *  &lt;dd&gt;Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="cm"> *      This option will automatically include the Logger widget&lt;/dd&gt;</span>
<span class="cm"> *  &lt;dt&gt;RAW&lt;/dt&gt;</span>
<span class="cm"> *  &lt;dd&gt;Selects the non-minified version of the library (e.g., event.js).</span>
<span class="cm"> *  &lt;/dd&gt;</span>
<span class="cm"> * &lt;/dl&gt;</span>
<span class="cm"> * You can also define a custom filter, which must be an object literal</span>
<span class="cm"> * containing a search expression and a replace string:</span>
<span class="cm"> * &lt;pre&gt;</span>
<span class="cm"> *  myFilter: &amp;#123;</span>
<span class="cm"> *      &#39;searchExp&#39;: &quot;-min\\.js&quot;,</span>
<span class="cm"> *      &#39;replaceStr&#39;: &quot;-debug.js&quot;</span>
<span class="cm"> *  &amp;#125;</span>
<span class="cm"> * &lt;/pre&gt;</span>
<span class="cm"> *</span>
<span class="cm"> *  &lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;filters: per-component filter specification.  If specified</span>
<span class="cm"> *  for a given component, this overrides the filter config&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;combine:</span>
<span class="cm"> *  Use the YUI combo service to reduce the number of http connections</span>
<span class="cm"> *  required to load your dependencies&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;ignore:</span>
<span class="cm"> *  A list of modules that should never be dynamically loaded&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;force:</span>
<span class="cm"> *  A list of modules that should always be loaded when required, even if</span>
<span class="cm"> *  already present on the page&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;insertBefore:</span>
<span class="cm"> *  Node or id for a node that should be used as the insertion point for</span>
<span class="cm"> *  new nodes&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;charset:</span>
<span class="cm"> *  charset for dynamic nodes (deprecated, use jsAttributes or cssAttributes)</span>
<span class="cm"> *  &lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;jsAttributes: object literal containing attributes to add to script</span>
<span class="cm"> *  nodes&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;cssAttributes: object literal containing attributes to add to link</span>
<span class="cm"> *  nodes&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;timeout:</span>
<span class="cm"> *  The number of milliseconds before a timeout occurs when dynamically</span>
<span class="cm"> *  loading nodes.  If not set, there is no timeout&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;context:</span>
<span class="cm"> *  execution context for all callbacks&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;onSuccess:</span>
<span class="cm"> *  callback for the &#39;success&#39; event&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;onFailure: callback for the &#39;failure&#39; event&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;onCSS: callback for the &#39;CSSComplete&#39; event.  When loading YUI</span>
<span class="cm"> *  components with CSS the CSS is loaded first, then the script.  This</span>
<span class="cm"> *  provides a moment you can tie into to improve</span>
<span class="cm"> *  the presentation of the page while the script is loading.&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;onTimeout:</span>
<span class="cm"> *  callback for the &#39;timeout&#39; event&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;onProgress:</span>
<span class="cm"> *  callback executed each time a script or css file is loaded&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;modules:</span>
<span class="cm"> *  A list of module definitions.  See Loader.addModule for the supported</span>
<span class="cm"> *  module metadata&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;groups:</span>
<span class="cm"> *  A list of group definitions.  Each group can contain specific definitions</span>
<span class="cm"> *  for base, comboBase, combine, and accepts a list of modules.  See above</span>
<span class="cm"> *  for the description of these properties.&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;2in3: the version of the YUI 2 in 3 wrapper to use.  The intrinsic</span>
<span class="cm"> *  support for YUI 2 modules in YUI 3 relies on versions of the YUI 2</span>
<span class="cm"> *  components inside YUI 3 module wrappers.  These wrappers</span>
<span class="cm"> *  change over time to accomodate the issues that arise from running YUI 2</span>
<span class="cm"> *  in a YUI 3 sandbox.&lt;/li&gt;</span>
<span class="cm"> *  &lt;li&gt;yui2: when using the 2in3 project, you can select the version of</span>
<span class="cm"> *  YUI 2 to use.  Valid values *  are 2.2.2, 2.3.1, 2.4.1, 2.5.2, 2.6.0,</span>
<span class="cm"> *  2.7.0, 2.8.0, and 2.8.1 [default] -- plus all versions of YUI 2</span>
<span class="cm"> *  going forward.&lt;/li&gt;</span>
<span class="cm"> * &lt;/ul&gt;</span>
<span class="cm"> */</span>
<span class="nx">Y</span><span class="p">.</span><span class="nx">Loader</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>

    <span class="kd">var</span> <span class="nx">defaults</span> <span class="o">=</span> <span class="nx">META</span><span class="p">.</span><span class="nx">modules</span><span class="p">,</span>
        <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>

    <span class="nx">modulekey</span> <span class="o">=</span> <span class="nx">META</span><span class="p">.</span><span class="nx">md5</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Internal callback to handle multiple internal insert() calls</span>
<span class="cm">     * so that css is inserted prior to js</span>
<span class="cm">     * @property _internalCallback</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="c1">// self._internalCallback = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Callback that will be executed when the loader is finished</span>
<span class="cm">     * with an insert</span>
<span class="cm">     * @method onSuccess</span>
<span class="cm">     * @type function</span>
<span class="cm">     */</span>
    <span class="c1">// self.onSuccess = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Callback that will be executed if there is a failure</span>
<span class="cm">     * @method onFailure</span>
<span class="cm">     * @type function</span>
<span class="cm">     */</span>
    <span class="c1">// self.onFailure = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Callback for the &#39;CSSComplete&#39; event.  When loading YUI components</span>
<span class="cm">     * with CSS the CSS is loaded first, then the script.  This provides</span>
<span class="cm">     * a moment you can tie into to improve the presentation of the page</span>
<span class="cm">     * while the script is loading.</span>
<span class="cm">     * @method onCSS</span>
<span class="cm">     * @type function</span>
<span class="cm">     */</span>
    <span class="c1">// self.onCSS = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Callback executed each time a script or css file is loaded</span>
<span class="cm">     * @method onProgress</span>
<span class="cm">     * @type function</span>
<span class="cm">     */</span>
    <span class="c1">// self.onProgress = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Callback that will be executed if a timeout occurs</span>
<span class="cm">     * @method onTimeout</span>
<span class="cm">     * @type function</span>
<span class="cm">     */</span>
    <span class="c1">// self.onTimeout = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * The execution context for all callbacks</span>
<span class="cm">     * @property context</span>
<span class="cm">     * @default {YUI} the YUI instance</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">context</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Data that is passed to all callbacks</span>
<span class="cm">     * @property data</span>
<span class="cm">     */</span>
    <span class="c1">// self.data = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Node reference or id where new nodes should be inserted before</span>
<span class="cm">     * @property insertBefore</span>
<span class="cm">     * @type string|HTMLElement</span>
<span class="cm">     */</span>
    <span class="c1">// self.insertBefore = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * The charset attribute for inserted nodes</span>
<span class="cm">     * @property charset</span>
<span class="cm">     * @type string</span>
<span class="cm">     * @deprecated , use cssAttributes or jsAttributes.</span>
<span class="cm">     */</span>
    <span class="c1">// self.charset = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * An object literal containing attributes to add to link nodes</span>
<span class="cm">     * @property cssAttributes</span>
<span class="cm">     * @type object</span>
<span class="cm">     */</span>
    <span class="c1">// self.cssAttributes = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * An object literal containing attributes to add to script nodes</span>
<span class="cm">     * @property jsAttributes</span>
<span class="cm">     * @type object</span>
<span class="cm">     */</span>
    <span class="c1">// self.jsAttributes = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * The base directory.</span>
<span class="cm">     * @property base</span>
<span class="cm">     * @type string</span>
<span class="cm">     * @default http://yui.yahooapis.com/[YUI VERSION]/build/</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">base</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">base</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Base path for the combo service</span>
<span class="cm">     * @property comboBase</span>
<span class="cm">     * @type string</span>
<span class="cm">     * @default http://yui.yahooapis.com/combo?</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">comboBase</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">comboBase</span><span class="p">;</span>

    <span class="cm">/*</span>
<span class="cm">     * Base path for language packs.</span>
<span class="cm">     */</span>
    <span class="c1">// self.langBase = Y.Env.meta.langBase;</span>
    <span class="c1">// self.lang = &quot;&quot;;</span>

    <span class="cm">/**</span>
<span class="cm">     * If configured, the loader will attempt to use the combo</span>
<span class="cm">     * service for YUI resources and configured external resources.</span>
<span class="cm">     * @property combine</span>
<span class="cm">     * @type boolean</span>
<span class="cm">     * @default true if a base dir isn&#39;t in the config</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">combine</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">base</span> <span class="o">&amp;&amp;</span>
        <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">base</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">comboBase</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">20</span><span class="p">))</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Max url length for combo urls.  The default is 2048 for</span>
<span class="cm">     * internet explorer, and 8192 otherwise.  This is the URL</span>
<span class="cm">     * limit for the Yahoo! hosted combo servers.  If consuming</span>
<span class="cm">     * a different combo service that has a different URL limit</span>
<span class="cm">     * it is possible to override this default by supplying</span>
<span class="cm">     * the maxURLLength config option.  The config option will</span>
<span class="cm">     * only take effect if lower than the default.</span>
<span class="cm">     *</span>
<span class="cm">     * Browsers:</span>
<span class="cm">     *    IE: 2048</span>
<span class="cm">     *    Other A-Grade Browsers: Higher that what is typically supported</span>
<span class="cm">     *    &#39;capable&#39; mobile browsers:</span>
<span class="cm">     *</span>
<span class="cm">     * Servers:</span>
<span class="cm">     *    Apache: 8192</span>
<span class="cm">     *</span>
<span class="cm">     * @property maxURLLength</span>
<span class="cm">     * @type int</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">maxURLLength</span> <span class="o">=</span> <span class="nx">MAX_URL_LENGTH</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Ignore modules registered on the YUI global</span>
<span class="cm">     * @property ignoreRegistered</span>
<span class="cm">     * @default false</span>
<span class="cm">     */</span>
    <span class="c1">// self.ignoreRegistered = false;</span>

    <span class="cm">/**</span>
<span class="cm">     * Root path to prepend to module path for the combo</span>
<span class="cm">     * service</span>
<span class="cm">     * @property root</span>
<span class="cm">     * @type string</span>
<span class="cm">     * @default [YUI VERSION]/build/</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">root</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">root</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * Timeout value in milliseconds.  If set, self value will be used by</span>
<span class="cm">     * the get utility.  the timeout event will fire if</span>
<span class="cm">     * a timeout occurs.</span>
<span class="cm">     * @property timeout</span>
<span class="cm">     * @type int</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">timeout</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * A list of modules that should not be loaded, even if</span>
<span class="cm">     * they turn up in the dependency tree</span>
<span class="cm">     * @property ignore</span>
<span class="cm">     * @type string[]</span>
<span class="cm">     */</span>
    <span class="c1">// self.ignore = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * A list of modules that should always be loaded, even</span>
<span class="cm">     * if they have already been inserted into the page.</span>
<span class="cm">     * @property force</span>
<span class="cm">     * @type string[]</span>
<span class="cm">     */</span>
    <span class="c1">// self.force = null;</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">forceMap</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/**</span>
<span class="cm">     * Should we allow rollups</span>
<span class="cm">     * @property allowRollup</span>
<span class="cm">     * @type boolean</span>
<span class="cm">     * @default true</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">allowRollup</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * A filter to apply to result urls.  This filter will modify the default</span>
<span class="cm">     * path for all modules.  The default path for the YUI library is the</span>
<span class="cm">     * minified version of the files (e.g., event-min.js).  The filter property</span>
<span class="cm">     * can be a predefined filter or a custom filter.  The valid predefined</span>
<span class="cm">     * filters are:</span>
<span class="cm">     * &lt;dl&gt;</span>
<span class="cm">     *  &lt;dt&gt;DEBUG&lt;/dt&gt;</span>
<span class="cm">     *  &lt;dd&gt;Selects the debug versions of the library (e.g., event-debug.js).</span>
<span class="cm">     *      This option will automatically include the Logger widget&lt;/dd&gt;</span>
<span class="cm">     *  &lt;dt&gt;RAW&lt;/dt&gt;</span>
<span class="cm">     *  &lt;dd&gt;Selects the non-minified version of the library (e.g., event.js).</span>
<span class="cm">     *  &lt;/dd&gt;</span>
<span class="cm">     * &lt;/dl&gt;</span>
<span class="cm">     * You can also define a custom filter, which must be an object literal</span>
<span class="cm">     * containing a search expression and a replace string:</span>
<span class="cm">     * &lt;pre&gt;</span>
<span class="cm">     *  myFilter: &amp;#123;</span>
<span class="cm">     *      &#39;searchExp&#39;: &quot;-min\\.js&quot;,</span>
<span class="cm">     *      &#39;replaceStr&#39;: &quot;-debug.js&quot;</span>
<span class="cm">     *  &amp;#125;</span>
<span class="cm">     * &lt;/pre&gt;</span>
<span class="cm">     * @property filter</span>
<span class="cm">     * @type string| {searchExp: string, replaceStr: string}</span>
<span class="cm">     */</span>
    <span class="c1">// self.filter = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * per-component filter specification.  If specified for a given</span>
<span class="cm">     * component, this overrides the filter config.</span>
<span class="cm">     * @property filters</span>
<span class="cm">     * @type object</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">filters</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/**</span>
<span class="cm">     * The list of requested modules</span>
<span class="cm">     * @property required</span>
<span class="cm">     * @type {string: boolean}</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">required</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/**</span>
<span class="cm">     * If a module name is predefined when requested, it is checked againsts</span>
<span class="cm">     * the patterns provided in this property.  If there is a match, the</span>
<span class="cm">     * module is added with the default configuration.</span>
<span class="cm">     *</span>
<span class="cm">     * At the moment only supporting module prefixes, but anticipate</span>
<span class="cm">     * supporting at least regular expressions.</span>
<span class="cm">     * @property patterns</span>
<span class="cm">     * @type Object</span>
<span class="cm">     */</span>
    <span class="c1">// self.patterns = Y.merge(Y.Env.meta.patterns);</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">patterns</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/**</span>
<span class="cm">     * The library metadata</span>
<span class="cm">     * @property moduleInfo</span>
<span class="cm">     */</span>
    <span class="c1">// self.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">moduleInfo</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">groups</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">groups</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * Provides the information used to skin the skinnable components.</span>
<span class="cm">     * The following skin definition would result in &#39;skin1&#39; and &#39;skin2&#39;</span>
<span class="cm">     * being loaded for calendar (if calendar was requested), and</span>
<span class="cm">     * &#39;sam&#39; for all other skinnable components:</span>
<span class="cm">     *</span>
<span class="cm">     *   &lt;code&gt;</span>
<span class="cm">     *   skin: {</span>
<span class="cm">     *</span>
<span class="cm">     *      // The default skin, which is automatically applied if not</span>
<span class="cm">     *      // overriden by a component-specific skin definition.</span>
<span class="cm">     *      // Change this in to apply a different skin globally</span>
<span class="cm">     *      defaultSkin: &#39;sam&#39;,</span>
<span class="cm">     *</span>
<span class="cm">     *      // This is combined with the loader base property to get</span>
<span class="cm">     *      // the default root directory for a skin. ex:</span>
<span class="cm">     *      // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/</span>
<span class="cm">     *      base: &#39;assets/skins/&#39;,</span>
<span class="cm">     *</span>
<span class="cm">     *      // Any component-specific overrides can be specified here,</span>
<span class="cm">     *      // making it possible to load different skins for different</span>
<span class="cm">     *      // components.  It is possible to load more than one skin</span>
<span class="cm">     *      // for a given component as well.</span>
<span class="cm">     *      overrides: {</span>
<span class="cm">     *          calendar: [&#39;skin1&#39;, &#39;skin2&#39;]</span>
<span class="cm">     *      }</span>
<span class="cm">     *   }</span>
<span class="cm">     *   &lt;/code&gt;</span>
<span class="cm">     *   @property skin</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">skin</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">meta</span><span class="p">.</span><span class="nx">skin</span><span class="p">);</span>

    <span class="cm">/*</span>
<span class="cm">     * Map of conditional modules</span>
<span class="cm">     * @since 3.2.0</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">conditions</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="c1">// map of modules with a hash of modules that meet the requirement</span>
    <span class="c1">// self.provides = {};</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">config</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">_internal</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>


    <span class="nx">cache</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_renderedMods</span><span class="p">;</span>

    <span class="k">if</span> <span class="p">(</span><span class="nx">cache</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">oeach</span><span class="p">(</span><span class="nx">cache</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">v</span><span class="p">);</span>
        <span class="p">});</span>

        <span class="nx">cache</span> <span class="o">=</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_conditions</span><span class="p">;</span>

        <span class="nx">oeach</span><span class="p">(</span><span class="nx">cache</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">conditions</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">v</span><span class="p">);</span>
        <span class="p">});</span>

    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
        <span class="nx">oeach</span><span class="p">(</span><span class="nx">defaults</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">addModule</span><span class="p">,</span> <span class="nx">self</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_renderedMods</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_renderedMods</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">);</span>
        <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">_conditions</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">conditions</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">_inspectPage</span><span class="p">();</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">_internal</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">_config</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>

    <span class="cm">/**</span>
<span class="cm">     * List of rollup files found in the library metadata</span>
<span class="cm">     * @property rollups</span>
<span class="cm">     */</span>
    <span class="c1">// self.rollups = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Whether or not to load optional dependencies for</span>
<span class="cm">     * the requested modules</span>
<span class="cm">     * @property loadOptional</span>
<span class="cm">     * @type boolean</span>
<span class="cm">     * @default false</span>
<span class="cm">     */</span>
    <span class="c1">// self.loadOptional = false;</span>

    <span class="cm">/**</span>
<span class="cm">     * All of the derived dependencies in sorted order, which</span>
<span class="cm">     * will be populated when either calculate() or insert()</span>
<span class="cm">     * is called</span>
<span class="cm">     * @property sorted</span>
<span class="cm">     * @type string[]</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">sorted</span> <span class="o">=</span> <span class="p">[];</span>

    <span class="cm">/**</span>
<span class="cm">     * Set when beginning to compute the dependency tree.</span>
<span class="cm">     * Composed of what YUI reports to be loaded combined</span>
<span class="cm">     * with what has been loaded by any instance on the page</span>
<span class="cm">     * with the version number specified in the metadata.</span>
<span class="cm">     * @property loaded</span>
<span class="cm">     * @type {string: boolean}</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">loaded</span> <span class="o">=</span> <span class="nx">GLOBAL_LOADED</span><span class="p">[</span><span class="nx">VERSION</span><span class="p">];</span>

    <span class="cm">/*</span>
<span class="cm">     * A list of modules to attach to the YUI instance when complete.</span>
<span class="cm">     * If not supplied, the sorted list of dependencies are applied.</span>
<span class="cm">     * @property attaching</span>
<span class="cm">     */</span>
    <span class="c1">// self.attaching = null;</span>

    <span class="cm">/**</span>
<span class="cm">     * Flag to indicate the dependency tree needs to be recomputed</span>
<span class="cm">     * if insert is called again.</span>
<span class="cm">     * @property dirty</span>
<span class="cm">     * @type boolean</span>
<span class="cm">     * @default true</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

    <span class="cm">/**</span>
<span class="cm">     * List of modules inserted by the utility</span>
<span class="cm">     * @property inserted</span>
<span class="cm">     * @type {string: boolean}</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/**</span>
<span class="cm">     * List of skipped modules during insert() because the module</span>
<span class="cm">     * was not defined</span>
<span class="cm">     * @property skipped</span>
<span class="cm">     */</span>
    <span class="nx">self</span><span class="p">.</span><span class="nx">skipped</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="c1">// Y.on(&#39;yui:load&#39;, self.loadNext, self);</span>

    <span class="nx">self</span><span class="p">.</span><span class="nx">tested</span> <span class="o">=</span> <span class="p">{};</span>

    <span class="cm">/*</span>
<span class="cm">     * Cached sorted calculate results</span>
<span class="cm">     * @property results</span>
<span class="cm">     * @since 3.2.0</span>
<span class="cm">     */</span>
    <span class="c1">//self.results = {};</span>

<span class="p">};</span>

<span class="nx">Y</span><span class="p">.</span><span class="nx">Loader</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="p">{</span>

    <span class="nx">FILTER_DEFS</span><span class="o">:</span> <span class="p">{</span>
        <span class="nx">RAW</span><span class="o">:</span> <span class="p">{</span>
            <span class="s1">&#39;searchExp&#39;</span><span class="o">:</span> <span class="s1">&#39;-min\\.js&#39;</span><span class="p">,</span>
            <span class="s1">&#39;replaceStr&#39;</span><span class="o">:</span> <span class="s1">&#39;.js&#39;</span>
        <span class="p">},</span>
        <span class="nx">DEBUG</span><span class="o">:</span> <span class="p">{</span>
            <span class="s1">&#39;searchExp&#39;</span><span class="o">:</span> <span class="s1">&#39;-min\\.js&#39;</span><span class="p">,</span>
            <span class="s1">&#39;replaceStr&#39;</span><span class="o">:</span> <span class="s1">&#39;-debug.js&#39;</span>
        <span class="p">}</span>
    <span class="p">},</span>

   <span class="nx">_inspectPage</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
       <span class="nx">oeach</span><span class="p">(</span><span class="nx">ON_PAGE</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
           <span class="k">if</span> <span class="p">(</span><span class="nx">v</span><span class="p">.</span><span class="nx">details</span><span class="p">)</span> <span class="p">{</span>
               <span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">k</span><span class="p">],</span>
                   <span class="nx">req</span> <span class="o">=</span> <span class="nx">v</span><span class="p">.</span><span class="nx">details</span><span class="p">.</span><span class="nx">requires</span><span class="p">,</span>
                   <span class="nx">mr</span> <span class="o">=</span> <span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">requires</span><span class="p">;</span>
               <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                   <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">m</span><span class="p">.</span><span class="nx">_inspected</span> <span class="o">&amp;&amp;</span> <span class="nx">req</span> <span class="o">&amp;&amp;</span> <span class="nx">mr</span><span class="p">.</span><span class="nx">length</span> <span class="o">!=</span> <span class="nx">req</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
                       <span class="c1">// console.log(&#39;deleting &#39; + m.name);</span>
                       <span class="k">delete</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expanded</span><span class="p">;</span>
                   <span class="p">}</span>
               <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                   <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">v</span><span class="p">.</span><span class="nx">details</span><span class="p">,</span> <span class="nx">k</span><span class="p">);</span>
               <span class="p">}</span>
               <span class="nx">m</span><span class="p">.</span><span class="nx">_inspected</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
           <span class="p">}</span>
       <span class="p">},</span> <span class="k">this</span><span class="p">);</span>
   <span class="p">},</span>

<span class="c1">// returns true if b is not loaded, and is required</span>
<span class="c1">// directly or by means of modules it supersedes.</span>
   <span class="nx">_requires</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">mod1</span><span class="p">,</span> <span class="nx">mod2</span><span class="p">)</span> <span class="p">{</span>

        <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">rm</span><span class="p">,</span> <span class="nx">after_map</span><span class="p">,</span> <span class="nx">s</span><span class="p">,</span>
            <span class="nx">info</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">,</span>
            <span class="nx">m</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod1</span><span class="p">],</span>
            <span class="nx">other</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod2</span><span class="p">];</span>
            <span class="c1">// key = mod1 + mod2;</span>

        <span class="c1">// if (this.tested[key]) {</span>
            <span class="c1">// return this.tested[key];</span>
        <span class="c1">// }</span>

        <span class="c1">// if (loaded[mod2] || !m || !other) {</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">m</span> <span class="o">||</span> <span class="o">!</span><span class="nx">other</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nx">rm</span> <span class="o">=</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span><span class="p">;</span>
        <span class="nx">after_map</span> <span class="o">=</span> <span class="nx">m</span><span class="p">.</span><span class="nx">after_map</span><span class="p">;</span>

        <span class="c1">// check if this module should be sorted after the other</span>
        <span class="c1">// do this first to short circut circular deps</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">after_map</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">mod2</span> <span class="k">in</span> <span class="nx">after_map</span><span class="p">))</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nx">after_map</span> <span class="o">=</span> <span class="nx">other</span><span class="p">.</span><span class="nx">after_map</span><span class="p">;</span>

        <span class="c1">// and vis-versa</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">after_map</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">mod1</span> <span class="k">in</span> <span class="nx">after_map</span><span class="p">))</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="c1">// check if this module requires one the other supersedes</span>
        <span class="nx">s</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod2</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod2</span><span class="p">].</span><span class="nx">supersedes</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_requires</span><span class="p">(</span><span class="nx">mod1</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]))</span> <span class="p">{</span>
                    <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nx">s</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod1</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod1</span><span class="p">].</span><span class="nx">supersedes</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_requires</span><span class="p">(</span><span class="nx">mod2</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]))</span> <span class="p">{</span>
                    <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// check if this module requires the other directly</span>
        <span class="c1">// if (r &amp;&amp; YArray.indexOf(r, mod2) &gt; -1) {</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">rm</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">mod2</span> <span class="k">in</span> <span class="nx">rm</span><span class="p">))</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="c1">// external css files should be sorted below yui css</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">ext</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="nx">CSS</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">other</span><span class="p">.</span><span class="nx">ext</span> <span class="o">&amp;&amp;</span> <span class="nx">other</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="nx">CSS</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="nx">_config</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">val</span><span class="p">,</span> <span class="nx">f</span><span class="p">,</span> <span class="nx">group</span><span class="p">,</span> <span class="nx">groupName</span><span class="p">,</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
        <span class="c1">// apply config values</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">val</span> <span class="o">=</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;require&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">self</span><span class="p">.</span><span class="nx">require</span><span class="p">(</span><span class="nx">val</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;skin&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">skin</span><span class="p">,</span> <span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="kc">true</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;groups&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="k">in</span> <span class="nx">val</span><span class="p">)</span> <span class="p">{</span>
                            <span class="k">if</span> <span class="p">(</span><span class="nx">val</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">j</span><span class="p">))</span> <span class="p">{</span>
                                <span class="c1">// Y.log(&#39;group: &#39; + j);</span>
                                <span class="nx">groupName</span> <span class="o">=</span> <span class="nx">j</span><span class="p">;</span>
                                <span class="nx">group</span> <span class="o">=</span> <span class="nx">val</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                                <span class="nx">self</span><span class="p">.</span><span class="nx">addGroup</span><span class="p">(</span><span class="nx">group</span><span class="p">,</span> <span class="nx">groupName</span><span class="p">);</span>
                            <span class="p">}</span>
                        <span class="p">}</span>

                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;modules&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="c1">// add a hash of module definitions</span>
                        <span class="nx">oeach</span><span class="p">(</span><span class="nx">val</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">addModule</span><span class="p">,</span> <span class="nx">self</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;gallery&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">groups</span><span class="p">.</span><span class="nx">gallery</span><span class="p">.</span><span class="nx">update</span><span class="p">(</span><span class="nx">val</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;yui2&#39;</span> <span class="o">||</span> <span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;2in3&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">groups</span><span class="p">.</span><span class="nx">yui2</span><span class="p">.</span><span class="nx">update</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="s1">&#39;2in3&#39;</span><span class="p">],</span> <span class="nx">o</span><span class="p">.</span><span class="nx">yui2</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">==</span> <span class="s1">&#39;maxURLLength&#39;</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">self</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="nx">MAX_URL_LENGTH</span><span class="p">,</span> <span class="nx">val</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                        <span class="nx">self</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">=</span> <span class="nx">val</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// fix filter</span>
        <span class="nx">f</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">filter</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">L</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">f</span><span class="p">))</span> <span class="p">{</span>
            <span class="nx">f</span> <span class="o">=</span> <span class="nx">f</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">();</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">filterName</span> <span class="o">=</span> <span class="nx">f</span><span class="p">;</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">FILTER_DEFS</span><span class="p">[</span><span class="nx">f</span><span class="p">];</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">f</span> <span class="o">==</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;yui-log&#39;</span><span class="p">,</span> <span class="s1">&#39;dump&#39;</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Returns the skin module name for the specified skin name.  If a</span>
<span class="cm">     * module name is supplied, the returned skin module name is</span>
<span class="cm">     * specific to the module passed in.</span>
<span class="cm">     * @method formatSkin</span>
<span class="cm">     * @param {string} skin the name of the skin.</span>
<span class="cm">     * @param {string} mod optional: the name of a module to skin.</span>
<span class="cm">     * @return {string} the full skin module name.</span>
<span class="cm">     */</span>
    <span class="nx">formatSkin</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">skin</span><span class="p">,</span> <span class="nx">mod</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="nx">SKIN_PREFIX</span> <span class="o">+</span> <span class="nx">skin</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">s</span> <span class="o">=</span> <span class="nx">s</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="nx">mod</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">s</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Adds the skin def to the module info</span>
<span class="cm">     * @method _addSkin</span>
<span class="cm">     * @param {string} skin the name of the skin.</span>
<span class="cm">     * @param {string} mod the name of the module.</span>
<span class="cm">     * @param {string} parent parent module if this is a skin of a</span>
<span class="cm">     * submodule or plugin.</span>
<span class="cm">     * @return {string} the module name for the skin.</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_addSkin</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">skin</span><span class="p">,</span> <span class="nx">mod</span><span class="p">,</span> <span class="nx">parent</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">mdef</span><span class="p">,</span> <span class="nx">pkg</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span>
            <span class="nx">info</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">,</span>
            <span class="nx">sinf</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">,</span>
            <span class="nx">ext</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod</span><span class="p">].</span><span class="nx">ext</span><span class="p">;</span>

        <span class="c1">// Add a module definition for the module-specific skin css</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">name</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">formatSkin</span><span class="p">(</span><span class="nx">skin</span><span class="p">,</span> <span class="nx">mod</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">info</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
                <span class="nx">mdef</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">mod</span><span class="p">];</span>
                <span class="nx">pkg</span> <span class="o">=</span> <span class="nx">mdef</span><span class="p">.</span><span class="nx">pkg</span> <span class="o">||</span> <span class="nx">mod</span><span class="p">;</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">({</span>
                    <span class="nx">name</span><span class="o">:</span> <span class="nx">name</span><span class="p">,</span>
                    <span class="nx">group</span><span class="o">:</span> <span class="nx">mdef</span><span class="p">.</span><span class="nx">group</span><span class="p">,</span>
                    <span class="nx">type</span><span class="o">:</span> <span class="s1">&#39;css&#39;</span><span class="p">,</span>
                    <span class="nx">after</span><span class="o">:</span> <span class="nx">sinf</span><span class="p">.</span><span class="nx">after</span><span class="p">,</span>
                    <span class="nx">path</span><span class="o">:</span> <span class="p">(</span><span class="nx">parent</span> <span class="o">||</span> <span class="nx">pkg</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">sinf</span><span class="p">.</span><span class="nx">base</span> <span class="o">+</span> <span class="nx">skin</span> <span class="o">+</span>
                          <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="nx">mod</span> <span class="o">+</span> <span class="s1">&#39;.css&#39;</span><span class="p">,</span>
                    <span class="nx">ext</span><span class="o">:</span> <span class="nx">ext</span>
                <span class="p">});</span>

                <span class="c1">// Y.log(&#39;adding skin &#39; + name + &#39;, &#39;</span>
                <span class="c1">// + parent + &#39;, &#39; + pkg + &#39;, &#39; + info[name].path);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">name</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/** Add a new module group</span>
<span class="cm">     * &lt;dl&gt;</span>
<span class="cm">     *   &lt;dt&gt;name:&lt;/dt&gt;      &lt;dd&gt;required, the group name&lt;/dd&gt;</span>
<span class="cm">     *   &lt;dt&gt;base:&lt;/dt&gt;      &lt;dd&gt;The base dir for this module group&lt;/dd&gt;</span>
<span class="cm">     *   &lt;dt&gt;root:&lt;/dt&gt;      &lt;dd&gt;The root path to add to each combo</span>
<span class="cm">     *   resource path&lt;/dd&gt;</span>
<span class="cm">     *   &lt;dt&gt;combine:&lt;/dt&gt;   &lt;dd&gt;combo handle&lt;/dd&gt;</span>
<span class="cm">     *   &lt;dt&gt;comboBase:&lt;/dt&gt; &lt;dd&gt;combo service base path&lt;/dd&gt;</span>
<span class="cm">     *   &lt;dt&gt;modules:&lt;/dt&gt;   &lt;dd&gt;the group of modules&lt;/dd&gt;</span>
<span class="cm">     * &lt;/dl&gt;</span>
<span class="cm">     * @method addGroup</span>
<span class="cm">     * @param {object} o An object containing the module data.</span>
<span class="cm">     * @param {string} name the group name.</span>
<span class="cm">     */</span>
    <span class="nx">addGroup</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">mods</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">modules</span><span class="p">,</span>
            <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
        <span class="nx">name</span> <span class="o">=</span> <span class="nx">name</span> <span class="o">||</span> <span class="nx">o</span><span class="p">.</span><span class="nx">name</span><span class="p">;</span>
        <span class="nx">o</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
        <span class="nx">self</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">patterns</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">oeach</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">patterns</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">v</span><span class="p">.</span><span class="nx">group</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">patterns</span><span class="p">[</span><span class="nx">k</span><span class="p">]</span> <span class="o">=</span> <span class="nx">v</span><span class="p">;</span>
            <span class="p">});</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">mods</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">oeach</span><span class="p">(</span><span class="nx">mods</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">v</span><span class="p">.</span><span class="nx">group</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">);</span>
            <span class="p">},</span> <span class="nx">self</span><span class="p">);</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="cm">/** Add a new module to the component metadata.</span>
<span class="cm">     * &lt;dl&gt;</span>
<span class="cm">     *     &lt;dt&gt;name:&lt;/dt&gt;       &lt;dd&gt;required, the component name&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;type:&lt;/dt&gt;       &lt;dd&gt;required, the component type (js or css)</span>
<span class="cm">     *     &lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;path:&lt;/dt&gt;       &lt;dd&gt;required, the path to the script from</span>
<span class="cm">     *     &quot;base&quot;&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;requires:&lt;/dt&gt;   &lt;dd&gt;array of modules required by this</span>
<span class="cm">     *     component&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;optional:&lt;/dt&gt;   &lt;dd&gt;array of optional modules for this</span>
<span class="cm">     *     component&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;supersedes:&lt;/dt&gt; &lt;dd&gt;array of the modules this component</span>
<span class="cm">     *     replaces&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;after:&lt;/dt&gt;      &lt;dd&gt;array of modules the components which, if</span>
<span class="cm">     *     present, should be sorted above this one&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;after_map:&lt;/dt&gt;  &lt;dd&gt;faster alternative to &#39;after&#39; -- supply</span>
<span class="cm">     *     a hash instead of an array&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;rollup:&lt;/dt&gt;     &lt;dd&gt;the number of superseded modules required</span>
<span class="cm">     *     for automatic rollup&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;fullpath:&lt;/dt&gt;   &lt;dd&gt;If fullpath is specified, this is used</span>
<span class="cm">     *     instead of the configured base + path&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;skinnable:&lt;/dt&gt;  &lt;dd&gt;flag to determine if skin assets should</span>
<span class="cm">     *     automatically be pulled in&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;submodules:&lt;/dt&gt; &lt;dd&gt;a hash of submodules&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;group:&lt;/dt&gt;      &lt;dd&gt;The group the module belongs to -- this</span>
<span class="cm">     *     is set automatically when it is added as part of a group</span>
<span class="cm">     *     configuration.&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;lang:&lt;/dt&gt;</span>
<span class="cm">     *       &lt;dd&gt;array of BCP 47 language tags of languages for which this</span>
<span class="cm">     *           module has localized resource bundles,</span>
<span class="cm">     *           e.g., [&quot;en-GB&quot;,&quot;zh-Hans-CN&quot;]&lt;/dd&gt;</span>
<span class="cm">     *     &lt;dt&gt;condition:&lt;/dt&gt;</span>
<span class="cm">     *       &lt;dd&gt;Specifies that the module should be loaded automatically if</span>
<span class="cm">     *           a condition is met.  This is an object with up to three fields:</span>
<span class="cm">     *           [trigger] - the name of a module that can trigger the auto-load</span>
<span class="cm">     *           [test] - a function that returns true when the module is to be</span>
<span class="cm">     *           loaded.</span>
<span class="cm">     *           [when] - specifies the load order of the conditional module</span>
<span class="cm">     *           with regard to the position of the trigger module.</span>
<span class="cm">     *           This should be one of three values: &#39;before&#39;, &#39;after&#39;, or</span>
<span class="cm">     *           &#39;instead&#39;.  The default is &#39;after&#39;.</span>
<span class="cm">     *       &lt;/dd&gt;</span>
<span class="cm">     * &lt;/dl&gt;</span>
<span class="cm">     * @method addModule</span>
<span class="cm">     * @param {object} o An object containing the module data.</span>
<span class="cm">     * @param {string} name the module name (optional), required if not</span>
<span class="cm">     * in the module data.</span>
<span class="cm">     * @return {object} the module definition or null if</span>
<span class="cm">     * the object passed in did not provide all required attributes.</span>
<span class="cm">     */</span>
    <span class="nx">addModule</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>

        <span class="nx">name</span> <span class="o">=</span> <span class="nx">name</span> <span class="o">||</span> <span class="nx">o</span><span class="p">.</span><span class="nx">name</span><span class="p">;</span>
        <span class="nx">o</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span> <span class="o">||</span> <span class="o">!</span><span class="nx">o</span><span class="p">.</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">o</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">JS</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span><span class="p">.</span><span class="nx">path</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">o</span><span class="p">.</span><span class="nx">fullpath</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">o</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">_path</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">||</span> <span class="nx">o</span><span class="p">.</span><span class="nx">use</span><span class="p">;</span>

        <span class="nx">o</span><span class="p">.</span><span class="nx">ext</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;ext&#39;</span> <span class="k">in</span> <span class="nx">o</span><span class="p">)</span> <span class="o">?</span> <span class="nx">o</span><span class="p">.</span><span class="nx">ext</span> <span class="o">:</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internal</span><span class="p">)</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="kc">true</span><span class="p">;</span>
        <span class="nx">o</span><span class="p">.</span><span class="nx">requires</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">requires</span> <span class="o">||</span> <span class="p">[];</span>

        <span class="c1">// Handle submodule logic</span>
        <span class="kd">var</span> <span class="nx">subs</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">submodules</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">l</span><span class="p">,</span> <span class="nx">sup</span><span class="p">,</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">smod</span><span class="p">,</span> <span class="nx">plugins</span><span class="p">,</span> <span class="nx">plug</span><span class="p">,</span>
            <span class="nx">j</span><span class="p">,</span> <span class="nx">langs</span><span class="p">,</span> <span class="nx">packName</span><span class="p">,</span> <span class="nx">supName</span><span class="p">,</span> <span class="nx">flatSup</span><span class="p">,</span> <span class="nx">flatLang</span><span class="p">,</span> <span class="nx">lang</span><span class="p">,</span> <span class="nx">ret</span><span class="p">,</span>
            <span class="nx">overrides</span><span class="p">,</span> <span class="nx">skinname</span><span class="p">,</span> <span class="nx">when</span><span class="p">,</span>
            <span class="nx">conditions</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">conditions</span><span class="p">,</span> <span class="nx">trigger</span><span class="p">;</span>
            <span class="c1">// , existing = this.moduleInfo[name], newr;</span>

        <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">o</span><span class="p">.</span><span class="nx">langPack</span> <span class="o">&amp;&amp;</span> <span class="nx">o</span><span class="p">.</span><span class="nx">lang</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">langs</span> <span class="o">=</span> <span class="nx">YArray</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">lang</span><span class="p">);</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">langs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">lang</span> <span class="o">=</span> <span class="nx">langs</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                <span class="nx">packName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">packName</span><span class="p">];</span>
                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">smod</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addLangPack</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">packName</span><span class="p">);</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">subs</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">sup</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">||</span> <span class="p">[];</span>
            <span class="nx">l</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">subs</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">subs</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">s</span> <span class="o">=</span> <span class="nx">subs</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>

                    <span class="nx">s</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">path</span> <span class="o">||</span> <span class="nx">_path</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">);</span>
                    <span class="nx">s</span><span class="p">.</span><span class="nx">pkg</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
                    <span class="nx">s</span><span class="p">.</span><span class="nx">group</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">group</span><span class="p">;</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">sup</span> <span class="o">=</span> <span class="nx">sup</span><span class="p">.</span><span class="nx">concat</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">);</span>
                    <span class="p">}</span>

                    <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>
                    <span class="nx">sup</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">smod</span><span class="p">.</span><span class="nx">skinnable</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">o</span><span class="p">.</span><span class="nx">skinnable</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                        <span class="nx">overrides</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">.</span><span class="nx">overrides</span><span class="p">;</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">overrides</span> <span class="o">&amp;&amp;</span> <span class="nx">overrides</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="p">{</span>
                            <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">overrides</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">skinname</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addSkin</span><span class="p">(</span><span class="nx">overrides</span><span class="p">[</span><span class="nx">i</span><span class="p">][</span><span class="nx">j</span><span class="p">],</span>
                                         <span class="nx">i</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                                <span class="nx">sup</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">skinname</span><span class="p">);</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                        <span class="nx">skinname</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addSkin</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">.</span><span class="nx">defaultSkin</span><span class="p">,</span>
                                        <span class="nx">i</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                        <span class="nx">sup</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">skinname</span><span class="p">);</span>
                    <span class="p">}</span>

                    <span class="c1">// looks like we are expected to work out the metadata</span>
                    <span class="c1">// for the parent module language packs from what is</span>
                    <span class="c1">// specified in the child modules.</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">lang</span> <span class="o">&amp;&amp;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>

                        <span class="nx">langs</span> <span class="o">=</span> <span class="nx">YArray</span><span class="p">(</span><span class="nx">s</span><span class="p">.</span><span class="nx">lang</span><span class="p">);</span>
                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">langs</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">lang</span> <span class="o">=</span> <span class="nx">langs</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                            <span class="nx">packName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                            <span class="nx">supName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>
                            <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">packName</span><span class="p">];</span>

                            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">smod</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addLangPack</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">packName</span><span class="p">);</span>
                            <span class="p">}</span>

                            <span class="nx">flatSup</span> <span class="o">=</span> <span class="nx">flatSup</span> <span class="o">||</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">smod</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">);</span>

                            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">supName</span> <span class="k">in</span> <span class="nx">flatSup</span><span class="p">))</span> <span class="p">{</span>
                                <span class="nx">smod</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">supName</span><span class="p">);</span>
                            <span class="p">}</span>

                            <span class="nx">o</span><span class="p">.</span><span class="nx">lang</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">lang</span> <span class="o">||</span> <span class="p">[];</span>

                            <span class="nx">flatLang</span> <span class="o">=</span> <span class="nx">flatLang</span> <span class="o">||</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">lang</span><span class="p">);</span>

                            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">lang</span> <span class="k">in</span> <span class="nx">flatLang</span><span class="p">))</span> <span class="p">{</span>
                                <span class="nx">o</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">lang</span><span class="p">);</span>
                            <span class="p">}</span>

<span class="c1">// Y.log(&#39;pack &#39; + packName + &#39; should supersede &#39; + supName);</span>
<span class="c1">// Add rollup file, need to add to supersedes list too</span>

                            <span class="c1">// default packages</span>
                            <span class="nx">packName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">ROOT_LANG</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                            <span class="nx">supName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">ROOT_LANG</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>

                            <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">packName</span><span class="p">];</span>

                            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">smod</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">smod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addLangPack</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">packName</span><span class="p">);</span>
                            <span class="p">}</span>

                            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">supName</span> <span class="k">in</span> <span class="nx">flatSup</span><span class="p">))</span> <span class="p">{</span>
                                <span class="nx">smod</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">supName</span><span class="p">);</span>
                            <span class="p">}</span>

<span class="c1">// Y.log(&#39;pack &#39; + packName + &#39; should supersede &#39; + supName);</span>
<span class="c1">// Add rollup file, need to add to supersedes list too</span>

                        <span class="p">}</span>
                    <span class="p">}</span>

                    <span class="nx">l</span><span class="o">++</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
            <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">=</span> <span class="nx">YObject</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">sup</span><span class="p">));</span>
            <span class="nx">o</span><span class="p">.</span><span class="nx">rollup</span> <span class="o">=</span> <span class="p">(</span><span class="nx">l</span> <span class="o">&lt;</span> <span class="mi">4</span><span class="p">)</span> <span class="o">?</span> <span class="nx">l</span> <span class="o">:</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="nx">l</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="nx">plugins</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">plugins</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">plugins</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">plugins</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">plugins</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">plug</span> <span class="o">=</span> <span class="nx">plugins</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                    <span class="nx">plug</span><span class="p">.</span><span class="nx">pkg</span> <span class="o">=</span> <span class="nx">name</span><span class="p">;</span>
                    <span class="nx">plug</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="nx">plug</span><span class="p">.</span><span class="nx">path</span> <span class="o">||</span> <span class="nx">_path</span><span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">o</span><span class="p">.</span><span class="nx">type</span><span class="p">);</span>
                    <span class="nx">plug</span><span class="p">.</span><span class="nx">requires</span> <span class="o">=</span> <span class="nx">plug</span><span class="p">.</span><span class="nx">requires</span> <span class="o">||</span> <span class="p">[];</span>
                    <span class="nx">plug</span><span class="p">.</span><span class="nx">group</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">group</span><span class="p">;</span>
                    <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">plug</span><span class="p">,</span> <span class="nx">i</span><span class="p">);</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">skinnable</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">_addSkin</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">.</span><span class="nx">defaultSkin</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                    <span class="p">}</span>

                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">condition</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">trigger</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">condition</span><span class="p">.</span><span class="nx">trigger</span><span class="p">;</span>
            <span class="nx">when</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">condition</span><span class="p">.</span><span class="nx">when</span><span class="p">;</span>
            <span class="nx">conditions</span><span class="p">[</span><span class="nx">trigger</span><span class="p">]</span> <span class="o">=</span> <span class="nx">conditions</span><span class="p">[</span><span class="nx">trigger</span><span class="p">]</span> <span class="o">||</span> <span class="p">{};</span>
            <span class="nx">conditions</span><span class="p">[</span><span class="nx">trigger</span><span class="p">][</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">condition</span><span class="p">;</span>
            <span class="c1">// the &#39;when&#39; attribute can be &#39;before&#39;, &#39;after&#39;, or &#39;instead&#39;</span>
            <span class="c1">// the default is after.</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">when</span> <span class="o">&amp;&amp;</span> <span class="nx">when</span> <span class="o">!=</span> <span class="s1">&#39;after&#39;</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">when</span> <span class="o">==</span> <span class="s1">&#39;instead&#39;</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// replace the trigger</span>
                    <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span> <span class="o">||</span> <span class="p">[];</span>
                    <span class="nx">o</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">trigger</span><span class="p">);</span>
                <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="c1">// before the trigger</span>
                    <span class="c1">// the trigger requires the conditional mod,</span>
                    <span class="c1">// so it should appear before the conditional</span>
                    <span class="c1">// mod if we do not intersede.</span>
                <span class="p">}</span>
            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="c1">// after the trigger</span>
                <span class="nx">o</span><span class="p">.</span><span class="nx">after</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">after</span> <span class="o">||</span> <span class="p">[];</span>
                <span class="nx">o</span><span class="p">.</span><span class="nx">after</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">trigger</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">after</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">o</span><span class="p">.</span><span class="nx">after_map</span> <span class="o">=</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">after</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// this.dirty = true;</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">configFn</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">ret</span> <span class="o">=</span> <span class="nx">o</span><span class="p">.</span><span class="nx">configFn</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">ret</span> <span class="o">===</span> <span class="kc">false</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">delete</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
                <span class="nx">o</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">o</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Add a requirement for one or more module</span>
<span class="cm">     * @method require</span>
<span class="cm">     * @param {string[] | string*} what the modules to load.</span>
<span class="cm">     */</span>
    <span class="nx">require</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">what</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">what</span> <span class="o">===</span> <span class="s1">&#39;string&#39;</span><span class="p">)</span> <span class="o">?</span> <span class="nx">arguments</span> <span class="o">:</span> <span class="nx">what</span><span class="p">;</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
        <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">required</span><span class="p">,</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">a</span><span class="p">));</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Returns an object containing properties for all modules required</span>
<span class="cm">     * in order to load the requested module</span>
<span class="cm">     * @method getRequires</span>
<span class="cm">     * @param {object}  mod The module definition from moduleInfo.</span>
<span class="cm">     * @return {array} the expanded requirement list.</span>
<span class="cm">     */</span>
    <span class="nx">getRequires</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">mod</span><span class="p">)</span> <span class="p">{</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">mod</span> <span class="o">||</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">_parsed</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// Y.log(&#39;returning no reqs for &#39; + mod.name);</span>
            <span class="k">return</span> <span class="nx">NO_REQUIREMENTS</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">add</span><span class="p">,</span> <span class="nx">packName</span><span class="p">,</span> <span class="nx">lang</span><span class="p">,</span>
            <span class="nx">name</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span> <span class="nx">cond</span><span class="p">,</span> <span class="nx">go</span><span class="p">,</span>
            <span class="nx">adddef</span> <span class="o">=</span> <span class="nx">ON_PAGE</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="nx">ON_PAGE</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">details</span><span class="p">,</span>
            <span class="nx">d</span><span class="p">,</span>
            <span class="nx">r</span><span class="p">,</span> <span class="nx">old_mod</span><span class="p">,</span>
            <span class="nx">o</span><span class="p">,</span> <span class="nx">skinmod</span><span class="p">,</span> <span class="nx">skindef</span><span class="p">,</span>
            <span class="nx">intl</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">lang</span> <span class="o">||</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">intl</span><span class="p">,</span>
            <span class="nx">info</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">,</span>
            <span class="nx">hash</span><span class="p">;</span>

        <span class="c1">// pattern match leaves module stub that needs to be filled out</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">temp</span> <span class="o">&amp;&amp;</span> <span class="nx">adddef</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">old_mod</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">;</span>
            <span class="nx">mod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">adddef</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
            <span class="nx">mod</span><span class="p">.</span><span class="nx">group</span> <span class="o">=</span> <span class="nx">old_mod</span><span class="p">.</span><span class="nx">group</span><span class="p">;</span>
            <span class="nx">mod</span><span class="p">.</span><span class="nx">pkg</span> <span class="o">=</span> <span class="nx">old_mod</span><span class="p">.</span><span class="nx">pkg</span><span class="p">;</span>
            <span class="k">delete</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">expanded</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="c1">// if (mod.expanded &amp;&amp; (!mod.langCache || mod.langCache == this.lang)) {</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">expanded</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">lang</span> <span class="o">||</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">langCache</span> <span class="o">===</span> <span class="k">this</span><span class="p">.</span><span class="nx">lang</span><span class="p">))</span> <span class="p">{</span>
            <span class="c1">// Y.log(&#39;already expanded &#39; + name + &#39;, &#39; + mod.expanded);</span>
            <span class="k">return</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">expanded</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="nx">d</span> <span class="o">=</span> <span class="p">[];</span>
        <span class="nx">hash</span> <span class="o">=</span> <span class="p">{};</span>

        <span class="nx">r</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">requires</span><span class="p">;</span>
        <span class="nx">o</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">optional</span><span class="p">;</span>

        <span class="c1">// Y.log(&quot;getRequires: &quot; + name + &quot; (dirty:&quot; + this.dirty +</span>
        <span class="c1">// &quot;, expanded:&quot; + mod.expanded + &quot;)&quot;);</span>

        <span class="nx">mod</span><span class="p">.</span><span class="nx">_parsed</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>


        <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">r</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// Y.log(name + &#39; requiring &#39; + r[i]);</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hash</span><span class="p">[</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]])</span> <span class="p">{</span>
                <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
                <span class="nx">hash</span><span class="p">[</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
                    <span class="nx">intl</span> <span class="o">=</span> <span class="nx">intl</span> <span class="o">||</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span> <span class="o">&amp;&amp;</span>
                        <span class="p">(</span><span class="nx">INTL</span> <span class="k">in</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span><span class="p">));</span>
                    <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">add</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">add</span><span class="p">[</span><span class="nx">j</span><span class="p">]);</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// get the requirements from superseded modules, if any</span>
        <span class="nx">r</span> <span class="o">=</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">r</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hash</span><span class="p">[</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]])</span> <span class="p">{</span>
                    <span class="c1">// if this module has submodules, the requirements list is</span>
                    <span class="c1">// expanded to include the submodules.  This is so we can</span>
                    <span class="c1">// prevent dups when a submodule is already loaded and the</span>
                    <span class="c1">// parent is requested.</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">submodules</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
                    <span class="p">}</span>

                    <span class="nx">hash</span><span class="p">[</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                    <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
                        <span class="nx">intl</span> <span class="o">=</span> <span class="nx">intl</span> <span class="o">||</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span> <span class="o">&amp;&amp;</span>
                            <span class="p">(</span><span class="nx">INTL</span> <span class="k">in</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span><span class="p">));</span>
                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">add</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">add</span><span class="p">[</span><span class="nx">j</span><span class="p">]);</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">loadOptional</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">o</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hash</span><span class="p">[</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]])</span> <span class="p">{</span>
                    <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
                    <span class="nx">hash</span><span class="p">[</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                    <span class="nx">m</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">o</span><span class="p">[</span><span class="nx">i</span><span class="p">]];</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
                        <span class="nx">intl</span> <span class="o">=</span> <span class="nx">intl</span> <span class="o">||</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span> <span class="o">&amp;&amp;</span>
                            <span class="p">(</span><span class="nx">INTL</span> <span class="k">in</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expanded_map</span><span class="p">));</span>
                        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">add</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">add</span><span class="p">[</span><span class="nx">j</span><span class="p">]);</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nx">cond</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">conditions</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">cond</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">oeach</span><span class="p">(</span><span class="nx">cond</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">def</span><span class="p">,</span> <span class="nx">condmod</span><span class="p">)</span> <span class="p">{</span>

                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">hash</span><span class="p">[</span><span class="nx">condmod</span><span class="p">])</span> <span class="p">{</span>
                    <span class="nx">go</span> <span class="o">=</span> <span class="nx">def</span> <span class="o">&amp;&amp;</span> <span class="p">((</span><span class="nx">def</span><span class="p">.</span><span class="nx">ua</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">UA</span><span class="p">[</span><span class="nx">def</span><span class="p">.</span><span class="nx">ua</span><span class="p">])</span> <span class="o">||</span>
                                 <span class="p">(</span><span class="nx">def</span><span class="p">.</span><span class="nx">test</span> <span class="o">&amp;&amp;</span> <span class="nx">def</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">Y</span><span class="p">,</span> <span class="nx">r</span><span class="p">)));</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">go</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">hash</span><span class="p">[</span><span class="nx">condmod</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                        <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">condmod</span><span class="p">);</span>
                        <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">condmod</span><span class="p">);</span>
                        <span class="c1">// Y.log(&#39;conditional&#39;, m);</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                            <span class="nx">add</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
                            <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">add</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                                <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">add</span><span class="p">[</span><span class="nx">j</span><span class="p">]);</span>
                            <span class="p">}</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">},</span> <span class="k">this</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// Create skin modules</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">skinnable</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">skindef</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">.</span><span class="nx">overrides</span><span class="p">;</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">skindef</span> <span class="o">&amp;&amp;</span> <span class="nx">skindef</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
                <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">skindef</span><span class="p">[</span><span class="nx">name</span><span class="p">].</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">skinmod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addSkin</span><span class="p">(</span><span class="nx">skindef</span><span class="p">[</span><span class="nx">name</span><span class="p">][</span><span class="nx">i</span><span class="p">],</span> <span class="nx">name</span><span class="p">);</span>
                    <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">skinmod</span><span class="p">);</span>
                <span class="p">}</span>
            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                <span class="nx">skinmod</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_addSkin</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">skin</span><span class="p">.</span><span class="nx">defaultSkin</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                <span class="nx">d</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">skinmod</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nx">mod</span><span class="p">.</span><span class="nx">_parsed</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">intl</span><span class="p">)</span> <span class="p">{</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">lang</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">mod</span><span class="p">.</span><span class="nx">langPack</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Intl</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">lang</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Intl</span><span class="p">.</span><span class="nx">lookupBestLang</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">lang</span> <span class="o">||</span> <span class="nx">ROOT_LANG</span><span class="p">,</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">lang</span><span class="p">);</span>
<span class="c1">// Y.log(&#39;Best lang: &#39; + lang + &#39;, this.lang: &#39; +</span>
<span class="c1">// this.lang + &#39;, mod.lang: &#39; + mod.lang);</span>
                <span class="nx">mod</span><span class="p">.</span><span class="nx">langCache</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">lang</span><span class="p">;</span>
                <span class="nx">packName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">packName</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">d</span><span class="p">.</span><span class="nx">unshift</span><span class="p">(</span><span class="nx">packName</span><span class="p">);</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="nx">d</span><span class="p">.</span><span class="nx">unshift</span><span class="p">(</span><span class="nx">INTL</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="nx">mod</span><span class="p">.</span><span class="nx">expanded_map</span> <span class="o">=</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">d</span><span class="p">);</span>

        <span class="nx">mod</span><span class="p">.</span><span class="nx">expanded</span> <span class="o">=</span> <span class="nx">YObject</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">mod</span><span class="p">.</span><span class="nx">expanded_map</span><span class="p">);</span>

        <span class="k">return</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">expanded</span><span class="p">;</span>
    <span class="p">},</span>


    <span class="cm">/**</span>
<span class="cm">     * Returns a hash of module names the supplied module satisfies.</span>
<span class="cm">     * @method getProvides</span>
<span class="cm">     * @param {string} name The name of the module.</span>
<span class="cm">     * @return {object} what this module provides.</span>
<span class="cm">     */</span>
    <span class="nx">getProvides</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">name</span><span class="p">),</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">s</span><span class="p">;</span>
            <span class="c1">// supmap = this.provides;</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="nx">NOT_FOUND</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">m</span><span class="p">.</span><span class="nx">provides</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">o</span> <span class="o">=</span> <span class="p">{};</span>
            <span class="nx">s</span> <span class="o">=</span> <span class="nx">m</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">;</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">YArray</span><span class="p">.</span><span class="nx">each</span><span class="p">(</span><span class="nx">s</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">getProvides</span><span class="p">(</span><span class="nx">v</span><span class="p">));</span>
                <span class="p">},</span> <span class="k">this</span><span class="p">);</span>
            <span class="p">}</span>

            <span class="nx">o</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="nx">m</span><span class="p">.</span><span class="nx">provides</span> <span class="o">=</span> <span class="nx">o</span><span class="p">;</span>

        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">m</span><span class="p">.</span><span class="nx">provides</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Calculates the dependency tree, the result is stored in the sorted</span>
<span class="cm">     * property.</span>
<span class="cm">     * @method calculate</span>
<span class="cm">     * @param {object} o optional options object.</span>
<span class="cm">     * @param {string} type optional argument to prune modules.</span>
<span class="cm">     */</span>
    <span class="nx">calculate</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">o</span> <span class="o">||</span> <span class="nx">type</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">dirty</span><span class="p">)</span> <span class="p">{</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">_config</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>
            <span class="p">}</span>

            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_init</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">_setup</span><span class="p">();</span>
            <span class="p">}</span>

            <span class="k">this</span><span class="p">.</span><span class="nx">_explode</span><span class="p">();</span>

            <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">allowRollup</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">this</span><span class="p">.</span><span class="nx">_rollup</span><span class="p">();</span>
            <span class="p">}</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">_reduce</span><span class="p">();</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">_sort</span><span class="p">();</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="nx">_addLangPack</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">packName</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">name</span> <span class="o">=</span> <span class="nx">m</span><span class="p">.</span><span class="nx">name</span><span class="p">,</span>
            <span class="nx">packPath</span><span class="p">,</span>
            <span class="nx">existing</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">packName</span><span class="p">];</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">existing</span><span class="p">)</span> <span class="p">{</span>

            <span class="nx">packPath</span> <span class="o">=</span> <span class="nx">_path</span><span class="p">((</span><span class="nx">m</span><span class="p">.</span><span class="nx">pkg</span> <span class="o">||</span> <span class="nx">name</span><span class="p">),</span> <span class="nx">packName</span><span class="p">,</span> <span class="nx">JS</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>

            <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">({</span> <span class="nx">path</span><span class="o">:</span> <span class="nx">packPath</span><span class="p">,</span>
                             <span class="nx">intl</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
                             <span class="nx">langPack</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
                             <span class="nx">ext</span><span class="o">:</span> <span class="nx">m</span><span class="p">.</span><span class="nx">ext</span><span class="p">,</span>
                             <span class="nx">group</span><span class="o">:</span> <span class="nx">m</span><span class="p">.</span><span class="nx">group</span><span class="p">,</span>
                             <span class="nx">supersedes</span><span class="o">:</span> <span class="p">[]</span> <span class="p">},</span> <span class="nx">packName</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">lang</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">lang</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">lang</span> <span class="o">||</span> <span class="p">{};</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">lang</span><span class="p">[</span><span class="nx">lang</span><span class="p">]</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">lang</span><span class="p">[</span><span class="nx">lang</span><span class="p">]</span> <span class="o">||</span> <span class="p">{};</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">lang</span><span class="p">[</span><span class="nx">lang</span><span class="p">][</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">packName</span><span class="p">];</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Investigates the current YUI configuration on the page.  By default,</span>
<span class="cm">     * modules already detected will not be loaded again unless a force</span>
<span class="cm">     * option is encountered.  Called by calculate()</span>
<span class="cm">     * @method _setup</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_setup</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">info</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">l</span><span class="p">,</span>
            <span class="nx">packName</span><span class="p">;</span>

        <span class="k">for</span> <span class="p">(</span><span class="nx">name</span> <span class="k">in</span> <span class="nx">info</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">info</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">name</span><span class="p">))</span> <span class="p">{</span>
                <span class="nx">m</span> <span class="o">=</span> <span class="nx">info</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>

                    <span class="c1">// remove dups</span>
                    <span class="nx">m</span><span class="p">.</span><span class="nx">requires</span> <span class="o">=</span> <span class="nx">YObject</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">requires</span><span class="p">));</span>

                    <span class="c1">// Create lang pack modules</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">lang</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
                        <span class="c1">// Setup root package if the module has lang defined,</span>
                        <span class="c1">// it needs to provide a root language pack</span>
                        <span class="nx">packName</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getLangPackName</span><span class="p">(</span><span class="nx">ROOT_LANG</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
                        <span class="k">this</span><span class="p">.</span><span class="nx">_addLangPack</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">packName</span><span class="p">);</span>
                    <span class="p">}</span>

                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>


        <span class="c1">//l = Y.merge(this.inserted);</span>
        <span class="nx">l</span> <span class="o">=</span> <span class="p">{};</span>

        <span class="c1">// available modules</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">ignoreRegistered</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">l</span><span class="p">,</span> <span class="nx">GLOBAL_ENV</span><span class="p">.</span><span class="nx">mods</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// add the ignore list to the list of loaded packages</span>
        <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">ignore</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">l</span><span class="p">,</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">ignore</span><span class="p">));</span>
        <span class="p">}</span>

        <span class="c1">// expand the list to include superseded modules</span>
        <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="k">in</span> <span class="nx">l</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">l</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">j</span><span class="p">))</span> <span class="p">{</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">l</span><span class="p">,</span> <span class="k">this</span><span class="p">.</span><span class="nx">getProvides</span><span class="p">(</span><span class="nx">j</span><span class="p">));</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// remove modules on the force list from the loaded list</span>
        <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">force</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">force</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">force</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">in</span> <span class="nx">l</span><span class="p">)</span> <span class="p">{</span>
                    <span class="k">delete</span> <span class="nx">l</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">force</span><span class="p">[</span><span class="nx">i</span><span class="p">]];</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">loaded</span><span class="p">,</span> <span class="nx">l</span><span class="p">);</span>

        <span class="k">this</span><span class="p">.</span><span class="nx">_init</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Builds a module name for a language pack</span>
<span class="cm">     * @method getLangPackName</span>
<span class="cm">     * @param {string} lang the language code.</span>
<span class="cm">     * @param {string} mname the module to build it for.</span>
<span class="cm">     * @return {string} the language pack module name.</span>
<span class="cm">     */</span>
    <span class="nx">getLangPackName</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">lang</span><span class="p">,</span> <span class="nx">mname</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">return</span> <span class="p">(</span><span class="s1">&#39;lang/&#39;</span> <span class="o">+</span> <span class="nx">mname</span> <span class="o">+</span> <span class="p">((</span><span class="nx">lang</span><span class="p">)</span> <span class="o">?</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="nx">lang</span> <span class="o">:</span> <span class="s1">&#39;&#39;</span><span class="p">));</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Inspects the required modules list looking for additional</span>
<span class="cm">     * dependencies.  Expands the required list to include all</span>
<span class="cm">     * required modules.  Called by calculate()</span>
<span class="cm">     * @method _explode</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_explode</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">r</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">required</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">reqs</span><span class="p">,</span> <span class="nx">done</span> <span class="o">=</span> <span class="p">{},</span>
            <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>

        <span class="c1">// the setup phase is over, all modules have been created</span>
        <span class="nx">self</span><span class="p">.</span><span class="nx">dirty</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

        <span class="nx">oeach</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">done</span><span class="p">[</span><span class="nx">name</span><span class="p">])</span> <span class="p">{</span>
                <span class="nx">done</span><span class="p">[</span><span class="nx">name</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="nx">m</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">name</span><span class="p">);</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                    <span class="kd">var</span> <span class="nx">expound</span> <span class="o">=</span> <span class="nx">m</span><span class="p">.</span><span class="nx">expound</span><span class="p">;</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">expound</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">r</span><span class="p">[</span><span class="nx">expound</span><span class="p">]</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">expound</span><span class="p">);</span>
                        <span class="nx">reqs</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">r</span><span class="p">[</span><span class="nx">expound</span><span class="p">]);</span>
                        <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">reqs</span><span class="p">));</span>
                    <span class="p">}</span>

                    <span class="nx">reqs</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getRequires</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
                    <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">r</span><span class="p">,</span> <span class="nx">YArray</span><span class="p">.</span><span class="nx">hash</span><span class="p">(</span><span class="nx">reqs</span><span class="p">));</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">});</span>

        <span class="c1">// Y.log(&#39;After explode: &#39; + YObject.keys(r));</span>
    <span class="p">},</span>

    <span class="nx">getModule</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">mname</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">//TODO: Remove name check - it&#39;s a quick hack to fix pattern WIP</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">mname</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="kd">var</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">found</span><span class="p">,</span> <span class="nx">pname</span><span class="p">,</span>
            <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">moduleInfo</span><span class="p">[</span><span class="nx">mname</span><span class="p">],</span>
            <span class="nx">patterns</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">patterns</span><span class="p">;</span>

        <span class="c1">// check the patterns library to see if we should automatically add</span>
        <span class="c1">// the module with defaults</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
           <span class="c1">// Y.log(&#39;testing patterns &#39; + YObject.keys(patterns));</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">pname</span> <span class="k">in</span> <span class="nx">patterns</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">patterns</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">pname</span><span class="p">))</span> <span class="p">{</span>
                    <span class="c1">// Y.log(&#39;testing pattern &#39; + i);</span>
                    <span class="nx">p</span> <span class="o">=</span> <span class="nx">patterns</span><span class="p">[</span><span class="nx">pname</span><span class="p">];</span>

                    <span class="c1">// use the metadata supplied for the pattern</span>
                    <span class="c1">// as the module definition.</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">mname</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">pname</span><span class="p">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">found</span> <span class="o">=</span> <span class="nx">p</span><span class="p">;</span>
                        <span class="k">break</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">found</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">p</span><span class="p">.</span><span class="nx">action</span><span class="p">)</span> <span class="p">{</span>
                    <span class="c1">// Y.log(&#39;executing pattern action: &#39; + pname);</span>
                    <span class="nx">p</span><span class="p">.</span><span class="nx">action</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">mname</span><span class="p">,</span> <span class="nx">pname</span><span class="p">);</span>
                <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;Undefined module: &#39;</span> <span class="o">+</span> <span class="nx">mname</span> <span class="o">+</span> <span class="s1">&#39;, matched a pattern: &#39;</span> <span class="o">+</span>
    <span class="nx">pname</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>
                    <span class="c1">// ext true or false?</span>
                    <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">addModule</span><span class="p">(</span><span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">found</span><span class="p">),</span> <span class="nx">mname</span><span class="p">);</span>
                    <span class="nx">m</span><span class="p">.</span><span class="nx">temp</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">m</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="c1">// impl in rollup submodule</span>
    <span class="nx">_rollup</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span> <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Remove superceded modules and loaded modules.  Called by</span>
<span class="cm">     * calculate() after we have the mega list of all dependencies</span>
<span class="cm">     * @method _reduce</span>
<span class="cm">     * @return {object} the reduced dependency hash.</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_reduce</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">r</span><span class="p">)</span> <span class="p">{</span>

        <span class="nx">r</span> <span class="o">=</span> <span class="nx">r</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">required</span><span class="p">;</span>

        <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">type</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">loadType</span><span class="p">;</span>
        <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="k">in</span> <span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">r</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">i</span><span class="p">))</span> <span class="p">{</span>
                <span class="nx">m</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
                <span class="c1">// remove if already loaded</span>
                <span class="k">if</span> <span class="p">(((</span><span class="k">this</span><span class="p">.</span><span class="nx">loaded</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">||</span> <span class="nx">ON_PAGE</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="o">&amp;&amp;</span>
                        <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">forceMap</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">ignoreRegistered</span><span class="p">)</span> <span class="o">||</span>
                        <span class="p">(</span><span class="nx">type</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">type</span> <span class="o">!=</span> <span class="nx">type</span><span class="p">))</span> <span class="p">{</span>
                    <span class="k">delete</span> <span class="nx">r</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
                <span class="p">}</span>
                <span class="c1">// remove anything this module supersedes</span>
                <span class="nx">s</span> <span class="o">=</span> <span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">supersedes</span><span class="p">;</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">)</span> <span class="p">{</span>
                    <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">[</span><span class="nx">j</span><span class="p">]</span> <span class="k">in</span> <span class="nx">r</span><span class="p">)</span> <span class="p">{</span>
                            <span class="k">delete</span> <span class="nx">r</span><span class="p">[</span><span class="nx">s</span><span class="p">[</span><span class="nx">j</span><span class="p">]];</span>
                        <span class="p">}</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>
        <span class="p">}</span>
        <span class="c1">// Y.log(&#39;required now: &#39; + YObject.keys(r));</span>

        <span class="k">return</span> <span class="nx">r</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="nx">_finish</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="nx">success</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;loader finishing: &#39;</span> <span class="o">+</span> <span class="nx">msg</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span> <span class="o">+</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span> <span class="o">+</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>

        <span class="nx">_queue</span><span class="p">.</span><span class="nx">running</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

        <span class="kd">var</span> <span class="nx">onEnd</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">onEnd</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">onEnd</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">onEnd</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="p">{</span>
                <span class="nx">msg</span><span class="o">:</span> <span class="nx">msg</span><span class="p">,</span>
                <span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span>
                <span class="nx">success</span><span class="o">:</span> <span class="nx">success</span>
            <span class="p">});</span>
        <span class="p">}</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_continue</span><span class="p">();</span>
    <span class="p">},</span>

    <span class="nx">_onSuccess</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span> <span class="nx">skipped</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">skipped</span><span class="p">),</span> <span class="nx">fn</span><span class="p">,</span>
            <span class="nx">failed</span> <span class="o">=</span> <span class="p">[],</span> <span class="nx">rreg</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">requireRegistration</span><span class="p">,</span>
            <span class="nx">success</span><span class="p">,</span> <span class="nx">msg</span><span class="p">;</span>

        <span class="nx">oeach</span><span class="p">(</span><span class="nx">skipped</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">delete</span> <span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span><span class="p">[</span><span class="nx">k</span><span class="p">];</span>
        <span class="p">});</span>

        <span class="nx">self</span><span class="p">.</span><span class="nx">skipped</span> <span class="o">=</span> <span class="p">{};</span>

        <span class="nx">oeach</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">v</span><span class="p">,</span> <span class="nx">k</span><span class="p">)</span> <span class="p">{</span>
            <span class="kd">var</span> <span class="nx">mod</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">k</span><span class="p">);</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">mod</span> <span class="o">&amp;&amp;</span> <span class="nx">rreg</span> <span class="o">&amp;&amp;</span> <span class="nx">mod</span><span class="p">.</span><span class="nx">type</span> <span class="o">==</span> <span class="nx">JS</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="p">(</span><span class="nx">k</span> <span class="k">in</span> <span class="nx">YUI</span><span class="p">.</span><span class="nx">Env</span><span class="p">.</span><span class="nx">mods</span><span class="p">))</span> <span class="p">{</span>
                <span class="nx">failed</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">k</span><span class="p">);</span>
            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">mix</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">loaded</span><span class="p">,</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getProvides</span><span class="p">(</span><span class="nx">k</span><span class="p">));</span>
            <span class="p">}</span>
        <span class="p">});</span>

        <span class="nx">fn</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">onSuccess</span><span class="p">;</span>
        <span class="nx">msg</span> <span class="o">=</span> <span class="p">(</span><span class="nx">failed</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">?</span> <span class="s1">&#39;notregistered&#39;</span> <span class="o">:</span> <span class="s1">&#39;success&#39;</span><span class="p">;</span>
        <span class="nx">success</span> <span class="o">=</span> <span class="o">!</span><span class="p">(</span><span class="nx">failed</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">fn</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="p">{</span>
                <span class="nx">msg</span><span class="o">:</span> <span class="nx">msg</span><span class="p">,</span>
                <span class="nx">data</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span>
                <span class="nx">success</span><span class="o">:</span> <span class="nx">success</span><span class="p">,</span>
                <span class="nx">failed</span><span class="o">:</span> <span class="nx">failed</span><span class="p">,</span>
                <span class="nx">skipped</span><span class="o">:</span> <span class="nx">skipped</span>
            <span class="p">});</span>
        <span class="p">}</span>
        <span class="nx">self</span><span class="p">.</span><span class="nx">_finish</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="nx">success</span><span class="p">);</span>
    <span class="p">},</span>
    <span class="nx">_onFailure</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;load error: &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="p">.</span><span class="nx">msg</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span> <span class="o">+</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>
        <span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">onFailure</span><span class="p">,</span> <span class="nx">msg</span> <span class="o">=</span> <span class="s1">&#39;failure: &#39;</span> <span class="o">+</span> <span class="nx">o</span><span class="p">.</span><span class="nx">msg</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">f</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="p">{</span>
                <span class="nx">msg</span><span class="o">:</span> <span class="nx">msg</span><span class="p">,</span>
                <span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span>
                <span class="nx">success</span><span class="o">:</span> <span class="kc">false</span>
            <span class="p">});</span>
        <span class="p">}</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_finish</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="nx">_onTimeout</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;loader timeout: &#39;</span> <span class="o">+</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">id</span><span class="p">,</span> <span class="s1">&#39;error&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>
        <span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">onTimeout</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">f</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="p">{</span>
                <span class="nx">msg</span><span class="o">:</span> <span class="s1">&#39;timeout&#39;</span><span class="p">,</span>
                <span class="nx">data</span><span class="o">:</span> <span class="k">this</span><span class="p">.</span><span class="nx">data</span><span class="p">,</span>
                <span class="nx">success</span><span class="o">:</span> <span class="kc">false</span>
            <span class="p">});</span>
        <span class="p">}</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_finish</span><span class="p">(</span><span class="s1">&#39;timeout&#39;</span><span class="p">,</span> <span class="kc">false</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Sorts the dependency tree.  The last step of calculate()</span>
<span class="cm">     * @method _sort</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_sort</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>

        <span class="c1">// create an indexed list</span>
        <span class="kd">var</span> <span class="nx">s</span> <span class="o">=</span> <span class="nx">YObject</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">required</span><span class="p">),</span>
            <span class="c1">// loaded = this.loaded,</span>
            <span class="nx">done</span> <span class="o">=</span> <span class="p">{},</span>
            <span class="nx">p</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">l</span><span class="p">,</span> <span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">moved</span><span class="p">,</span> <span class="nx">doneKey</span><span class="p">;</span>


        <span class="c1">// keep going until we make a pass without moving anything</span>
        <span class="k">for</span> <span class="p">(;;)</span> <span class="p">{</span>

            <span class="nx">l</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>
            <span class="nx">moved</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>

            <span class="c1">// start the loop after items that are already sorted</span>
            <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="o">=</span> <span class="nx">p</span><span class="p">;</span> <span class="nx">j</span> <span class="o">&lt;</span> <span class="nx">l</span><span class="p">;</span> <span class="nx">j</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>

                <span class="c1">// check the next module on the list to see if its</span>
                <span class="c1">// dependencies have been met</span>
                <span class="nx">a</span> <span class="o">=</span> <span class="nx">s</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>

                <span class="c1">// check everything below current item and move if we</span>
                <span class="c1">// find a requirement for the current item</span>
                <span class="k">for</span> <span class="p">(</span><span class="nx">k</span> <span class="o">=</span> <span class="nx">j</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span> <span class="nx">k</span> <span class="o">&lt;</span> <span class="nx">l</span><span class="p">;</span> <span class="nx">k</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">doneKey</span> <span class="o">=</span> <span class="nx">a</span> <span class="o">+</span> <span class="nx">s</span><span class="p">[</span><span class="nx">k</span><span class="p">];</span>

                    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">done</span><span class="p">[</span><span class="nx">doneKey</span><span class="p">]</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">_requires</span><span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="nx">k</span><span class="p">]))</span> <span class="p">{</span>

                        <span class="c1">// extract the dependency so we can move it up</span>
                        <span class="nx">b</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">k</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>

                        <span class="c1">// insert the dependency above the item that</span>
                        <span class="c1">// requires it</span>
                        <span class="nx">s</span><span class="p">.</span><span class="nx">splice</span><span class="p">(</span><span class="nx">j</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nx">b</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>

                        <span class="c1">// only swap two dependencies once to short circut</span>
                        <span class="c1">// circular dependencies</span>
                        <span class="nx">done</span><span class="p">[</span><span class="nx">doneKey</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

                        <span class="c1">// keep working</span>
                        <span class="nx">moved</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

                        <span class="k">break</span><span class="p">;</span>
                    <span class="p">}</span>
                <span class="p">}</span>

                <span class="c1">// jump out of loop if we moved something</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">moved</span><span class="p">)</span> <span class="p">{</span>
                    <span class="k">break</span><span class="p">;</span>
                <span class="c1">// this item is sorted, move our pointer and keep going</span>
                <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">p</span><span class="o">++</span><span class="p">;</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="c1">// when we make it here and moved is false, we are</span>
            <span class="c1">// finished sorting</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">moved</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">break</span><span class="p">;</span>
            <span class="p">}</span>

        <span class="p">}</span>

        <span class="k">this</span><span class="p">.</span><span class="nx">sorted</span> <span class="o">=</span> <span class="nx">s</span><span class="p">;</span>

    <span class="p">},</span>

    <span class="nx">partial</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">partial</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">sorted</span> <span class="o">=</span> <span class="nx">partial</span><span class="p">;</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">insert</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="kc">true</span><span class="p">);</span>
    <span class="p">},</span>

    <span class="nx">_insert</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">source</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">skipcalc</span><span class="p">)</span> <span class="p">{</span>

<span class="c1">// Y.log(&#39;private _insert() &#39; + (type || &#39;&#39;) + &#39;, &#39; + Y.id, &quot;info&quot;, &quot;loader&quot;);</span>

        <span class="c1">// restore the state at the time of the request</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">source</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">_config</span><span class="p">(</span><span class="nx">source</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// build the dependency list</span>
        <span class="c1">// don&#39;t include type so we can process CSS and script in</span>
        <span class="c1">// one pass when the type is not specified.</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">skipcalc</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">calculate</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="k">this</span><span class="p">.</span><span class="nx">loadType</span> <span class="o">=</span> <span class="nx">type</span><span class="p">;</span>

        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>

            <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>

            <span class="c1">// Y.log(&quot;trying to load css first&quot;);</span>
            <span class="k">this</span><span class="p">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>

                <span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">onCSS</span><span class="p">,</span> <span class="nx">n</span><span class="p">,</span> <span class="nx">p</span><span class="p">,</span> <span class="nx">sib</span><span class="p">;</span>

                <span class="c1">// IE hack for style overrides that are not being applied</span>
                <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">insertBefore</span> <span class="o">&amp;&amp;</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">UA</span><span class="p">.</span><span class="nx">ie</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">n</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">doc</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">);</span>
                    <span class="nx">p</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">;</span>
                    <span class="nx">sib</span> <span class="o">=</span> <span class="nx">n</span><span class="p">.</span><span class="nx">nextSibling</span><span class="p">;</span>
                    <span class="nx">p</span><span class="p">.</span><span class="nx">removeChild</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">sib</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">p</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">(</span><span class="nx">n</span><span class="p">,</span> <span class="nx">sib</span><span class="p">);</span>
                    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                        <span class="nx">p</span><span class="p">.</span><span class="nx">appendChild</span><span class="p">(</span><span class="nx">n</span><span class="p">);</span>
                    <span class="p">}</span>
                <span class="p">}</span>

                <span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">f</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="nx">Y</span><span class="p">);</span>
                <span class="p">}</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

                <span class="nx">self</span><span class="p">.</span><span class="nx">_insert</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">JS</span><span class="p">);</span>
            <span class="p">};</span>

            <span class="k">this</span><span class="p">.</span><span class="nx">_insert</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="kc">null</span><span class="p">,</span> <span class="nx">CSS</span><span class="p">);</span>

            <span class="k">return</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="c1">// set a flag to indicate the load has started</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>

        <span class="c1">// flag to indicate we are done with the combo service</span>
        <span class="c1">// and any additional files will need to be loaded</span>
        <span class="c1">// individually</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_combineComplete</span> <span class="o">=</span> <span class="p">{};</span>

        <span class="c1">// start the load</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">loadNext</span><span class="p">();</span>

    <span class="p">},</span>

    <span class="c1">// Once a loader operation is completely finished, process</span>
    <span class="c1">// any additional queued items.</span>
    <span class="nx">_continue</span><span class="o">:</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">_queue</span><span class="p">.</span><span class="nx">running</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nx">_queue</span><span class="p">.</span><span class="nx">size</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
            <span class="nx">_queue</span><span class="p">.</span><span class="nx">running</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="nx">_queue</span><span class="p">.</span><span class="nx">next</span><span class="p">()();</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * inserts the requested modules and their dependencies.</span>
<span class="cm">     * &lt;code&gt;type&lt;/code&gt; can be &quot;js&quot; or &quot;css&quot;.  Both script and</span>
<span class="cm">     * css are inserted if type is not provided.</span>
<span class="cm">     * @method insert</span>
<span class="cm">     * @param {object} o optional options object.</span>
<span class="cm">     * @param {string} type the type of dependency to insert.</span>
<span class="cm">     */</span>
    <span class="nx">insert</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">skipsort</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// Y.log(&#39;public insert() &#39; + (type || &#39;&#39;) + &#39;, &#39; +</span>
        <span class="c1">//  Y.Object.keys(this.required), &quot;info&quot;, &quot;loader&quot;);</span>
        <span class="kd">var</span> <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span> <span class="nx">copy</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">merge</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
        <span class="k">delete</span> <span class="nx">copy</span><span class="p">.</span><span class="nx">require</span><span class="p">;</span>
        <span class="k">delete</span> <span class="nx">copy</span><span class="p">.</span><span class="nx">dirty</span><span class="p">;</span>
        <span class="nx">_queue</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">_insert</span><span class="p">(</span><span class="nx">copy</span><span class="p">,</span> <span class="nx">o</span><span class="p">,</span> <span class="nx">type</span><span class="p">,</span> <span class="nx">skipsort</span><span class="p">);</span>
        <span class="p">});</span>
        <span class="k">this</span><span class="p">.</span><span class="nx">_continue</span><span class="p">();</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Executed every time a module is loaded, and if we are in a load</span>
<span class="cm">     * cycle, we attempt to load the next script.  Public so that it</span>
<span class="cm">     * is possible to call this if using a method other than</span>
<span class="cm">     * Y.register to determine when scripts are fully loaded</span>
<span class="cm">     * @method loadNext</span>
<span class="cm">     * @param {string} mname optional the name of the module that has</span>
<span class="cm">     * been loaded (which is usually why it is time to load the next</span>
<span class="cm">     * one).</span>
<span class="cm">     */</span>
    <span class="nx">loadNext</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">mname</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// It is possible that this function is executed due to something</span>
        <span class="c1">// else one the page loading a YUI module.  Only react when we</span>
        <span class="c1">// are actively loading something</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">_loading</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">return</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="kd">var</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">len</span><span class="p">,</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">m</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="nx">fn</span><span class="p">,</span> <span class="nx">msg</span><span class="p">,</span> <span class="nx">attr</span><span class="p">,</span> <span class="nx">group</span><span class="p">,</span> <span class="nx">groupName</span><span class="p">,</span> <span class="nx">j</span><span class="p">,</span> <span class="nx">frag</span><span class="p">,</span>
            <span class="nx">comboSource</span><span class="p">,</span> <span class="nx">comboSources</span><span class="p">,</span> <span class="nx">mods</span><span class="p">,</span> <span class="nx">combining</span><span class="p">,</span> <span class="nx">urls</span><span class="p">,</span> <span class="nx">comboBase</span><span class="p">,</span>
            <span class="nx">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">,</span>
            <span class="nx">type</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">loadType</span><span class="p">,</span>
            <span class="nx">handleSuccess</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">loadNext</span><span class="p">(</span><span class="nx">o</span><span class="p">.</span><span class="nx">data</span><span class="p">);</span>
            <span class="p">},</span>
            <span class="nx">handleCombo</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">o</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">_combineComplete</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">len</span> <span class="o">=</span> <span class="nx">combining</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>

                <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span><span class="p">[</span><span class="nx">combining</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="p">}</span>

                <span class="nx">handleSuccess</span><span class="p">(</span><span class="nx">o</span><span class="p">);</span>
            <span class="p">};</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">combine</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="o">!</span><span class="nx">self</span><span class="p">.</span><span class="nx">_combineComplete</span><span class="p">[</span><span class="nx">type</span><span class="p">]))</span> <span class="p">{</span>

            <span class="nx">combining</span> <span class="o">=</span> <span class="p">[];</span>

            <span class="nx">self</span><span class="p">.</span><span class="nx">_combining</span> <span class="o">=</span> <span class="nx">combining</span><span class="p">;</span>
            <span class="nx">s</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">sorted</span><span class="p">;</span>
            <span class="nx">len</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>

            <span class="c1">// the default combo base</span>
            <span class="nx">comboBase</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">comboBase</span><span class="p">;</span>

            <span class="nx">url</span> <span class="o">=</span> <span class="nx">comboBase</span><span class="p">;</span>
            <span class="nx">urls</span> <span class="o">=</span> <span class="p">[];</span>

            <span class="nx">comboSources</span> <span class="o">=</span> <span class="p">{};</span>

            <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">comboSource</span> <span class="o">=</span> <span class="nx">comboBase</span><span class="p">;</span>
                <span class="nx">m</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
                <span class="nx">groupName</span> <span class="o">=</span> <span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="nx">m</span><span class="p">.</span><span class="nx">group</span><span class="p">;</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">groupName</span><span class="p">)</span> <span class="p">{</span>

                    <span class="nx">group</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">groupName</span><span class="p">];</span>

                    <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">group</span><span class="p">.</span><span class="nx">combine</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">m</span><span class="p">.</span><span class="nx">combine</span> <span class="o">=</span> <span class="kc">false</span><span class="p">;</span>
                        <span class="k">continue</span><span class="p">;</span>
                    <span class="p">}</span>
                    <span class="nx">m</span><span class="p">.</span><span class="nx">combine</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                    <span class="k">if</span> <span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">comboBase</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">comboSource</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">comboBase</span><span class="p">;</span>
                    <span class="p">}</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">group</span><span class="p">.</span><span class="nx">root</span><span class="p">)</span> <span class="p">{</span>
                        <span class="nx">m</span><span class="p">.</span><span class="nx">root</span> <span class="o">=</span> <span class="nx">group</span><span class="p">.</span><span class="nx">root</span><span class="p">;</span>
                    <span class="p">}</span>

                <span class="p">}</span>

                <span class="nx">comboSources</span><span class="p">[</span><span class="nx">comboSource</span><span class="p">]</span> <span class="o">=</span> <span class="nx">comboSources</span><span class="p">[</span><span class="nx">comboSource</span><span class="p">]</span> <span class="o">||</span> <span class="p">[];</span>
                <span class="nx">comboSources</span><span class="p">[</span><span class="nx">comboSource</span><span class="p">].</span><span class="nx">push</span><span class="p">(</span><span class="nx">m</span><span class="p">);</span>
            <span class="p">}</span>

            <span class="k">for</span> <span class="p">(</span><span class="nx">j</span> <span class="k">in</span> <span class="nx">comboSources</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">comboSources</span><span class="p">.</span><span class="nx">hasOwnProperty</span><span class="p">(</span><span class="nx">j</span><span class="p">))</span> <span class="p">{</span>
                    <span class="nx">url</span> <span class="o">=</span> <span class="nx">j</span><span class="p">;</span>
                    <span class="nx">mods</span> <span class="o">=</span> <span class="nx">comboSources</span><span class="p">[</span><span class="nx">j</span><span class="p">];</span>
                    <span class="nx">len</span> <span class="o">=</span> <span class="nx">mods</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>

                    <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
                        <span class="c1">// m = self.getModule(s[i]);</span>
                        <span class="nx">m</span> <span class="o">=</span> <span class="nx">mods</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>

                        <span class="c1">// Do not try to combine non-yui JS unless combo def</span>
                        <span class="c1">// is found</span>
                        <span class="k">if</span> <span class="p">(</span><span class="nx">m</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="nx">type</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">combine</span> <span class="o">||</span> <span class="o">!</span><span class="nx">m</span><span class="p">.</span><span class="nx">ext</span><span class="p">))</span> <span class="p">{</span>

                            <span class="nx">frag</span> <span class="o">=</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">root</span> <span class="o">||</span> <span class="nx">self</span><span class="p">.</span><span class="nx">root</span><span class="p">)</span> <span class="o">+</span> <span class="nx">m</span><span class="p">.</span><span class="nx">path</span><span class="p">;</span>

                            <span class="k">if</span> <span class="p">((</span><span class="nx">url</span> <span class="o">!==</span> <span class="nx">j</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nx">len</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span> <span class="o">&amp;&amp;</span>
                            <span class="p">((</span><span class="nx">frag</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="nx">url</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nx">self</span><span class="p">.</span><span class="nx">maxURLLength</span><span class="p">))</span> <span class="p">{</span>
                                <span class="nx">urls</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">_filter</span><span class="p">(</span><span class="nx">url</span><span class="p">));</span>
                                <span class="nx">url</span> <span class="o">=</span> <span class="nx">j</span><span class="p">;</span>
                            <span class="p">}</span>

                            <span class="nx">url</span> <span class="o">+=</span> <span class="nx">frag</span><span class="p">;</span>
                            <span class="k">if</span> <span class="p">(</span><span class="nx">i</span> <span class="o">&lt;</span> <span class="p">(</span><span class="nx">len</span> <span class="o">-</span> <span class="mi">1</span><span class="p">))</span> <span class="p">{</span>
                                <span class="nx">url</span> <span class="o">+=</span> <span class="s1">&#39;&amp;&#39;</span><span class="p">;</span>
                            <span class="p">}</span>

                            <span class="nx">combining</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">name</span><span class="p">);</span>
                        <span class="p">}</span>

                    <span class="p">}</span>

                    <span class="k">if</span> <span class="p">(</span><span class="nx">combining</span><span class="p">.</span><span class="nx">length</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">url</span> <span class="o">!=</span> <span class="nx">j</span><span class="p">))</span> <span class="p">{</span>
                        <span class="nx">urls</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">_filter</span><span class="p">(</span><span class="nx">url</span><span class="p">));</span>
                    <span class="p">}</span>
                <span class="p">}</span>
            <span class="p">}</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">combining</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>

<span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;Attempting to use combo: &#39;</span> <span class="o">+</span> <span class="nx">combining</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>

                <span class="c1">// if (m.type === CSS) {</span>
                <span class="k">if</span> <span class="p">(</span><span class="nx">type</span> <span class="o">===</span> <span class="nx">CSS</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">fn</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Get</span><span class="p">.</span><span class="nx">css</span><span class="p">;</span>
                    <span class="nx">attr</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">cssAttributes</span><span class="p">;</span>
                <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">fn</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Get</span><span class="p">.</span><span class="nx">script</span><span class="p">;</span>
                    <span class="nx">attr</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">jsAttributes</span><span class="p">;</span>
                <span class="p">}</span>

                <span class="nx">fn</span><span class="p">(</span><span class="nx">urls</span><span class="p">,</span> <span class="p">{</span>
                    <span class="nx">data</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_loading</span><span class="p">,</span>
                    <span class="nx">onSuccess</span><span class="o">:</span> <span class="nx">handleCombo</span><span class="p">,</span>
                    <span class="nx">onFailure</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_onFailure</span><span class="p">,</span>
                    <span class="nx">onTimeout</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_onTimeout</span><span class="p">,</span>
                    <span class="nx">insertBefore</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">,</span>
                    <span class="nx">charset</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">charset</span><span class="p">,</span>
                    <span class="nx">attributes</span><span class="o">:</span> <span class="nx">attr</span><span class="p">,</span>
                    <span class="nx">timeout</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">timeout</span><span class="p">,</span>
                    <span class="nx">autopurge</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
                    <span class="nx">context</span><span class="o">:</span> <span class="nx">self</span>
                <span class="p">});</span>

                <span class="k">return</span><span class="p">;</span>

            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">_combineComplete</span><span class="p">[</span><span class="nx">type</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">mname</span><span class="p">)</span> <span class="p">{</span>

            <span class="c1">// if the module that was just loaded isn&#39;t what we were expecting,</span>
            <span class="c1">// continue to wait</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">mname</span> <span class="o">!==</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_loading</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">return</span><span class="p">;</span>
            <span class="p">}</span>

<span class="c1">// Y.log(&quot;loadNext executing, just loaded &quot; + mname + &quot;, &quot; +</span>
<span class="c1">// Y.id, &quot;info&quot;, &quot;loader&quot;);</span>

            <span class="c1">// The global handler that is called when each module is loaded</span>
            <span class="c1">// will pass that module name to this function.  Storing this</span>
            <span class="c1">// data to avoid loading the same module multiple times</span>
            <span class="c1">// centralize this in the callback</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span><span class="p">[</span><span class="nx">mname</span><span class="p">]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
            <span class="c1">// self.loaded[mname] = true;</span>

            <span class="c1">// provided = self.getProvides(mname);</span>
            <span class="c1">// Y.mix(self.loaded, provided);</span>
            <span class="c1">// Y.mix(self.inserted, provided);</span>

            <span class="k">if</span> <span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">onProgress</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">onProgress</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="p">.</span><span class="nx">context</span><span class="p">,</span> <span class="p">{</span>
                        <span class="nx">name</span><span class="o">:</span> <span class="nx">mname</span><span class="p">,</span>
                        <span class="nx">data</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">data</span>
                    <span class="p">});</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="nx">s</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">sorted</span><span class="p">;</span>
        <span class="nx">len</span> <span class="o">=</span> <span class="nx">s</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span>

        <span class="k">for</span> <span class="p">(</span><span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="p">;</span> <span class="nx">i</span> <span class="o">=</span> <span class="nx">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// this.inserted keeps track of what the loader has loaded.</span>
            <span class="c1">// move on if this item is done.</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="k">in</span> <span class="nx">self</span><span class="p">.</span><span class="nx">inserted</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">continue</span><span class="p">;</span>
            <span class="p">}</span>

            <span class="c1">// Because rollups will cause multiple load notifications</span>
            <span class="c1">// from Y, loadNext may be called multiple times for</span>
            <span class="c1">// the same module when loading a rollup.  We can safely</span>
            <span class="c1">// skip the subsequent requests</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">===</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_loading</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;still loading &#39;</span> <span class="o">+</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;, waiting&#39;</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>
                <span class="k">return</span><span class="p">;</span>
            <span class="p">}</span>

            <span class="c1">// log(&quot;inserting &quot; + s[i]);</span>
            <span class="nx">m</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">getModule</span><span class="p">(</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>

            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">m</span><span class="p">)</span> <span class="p">{</span>
                <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">self</span><span class="p">.</span><span class="nx">skipped</span><span class="p">[</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]])</span> <span class="p">{</span>
                    <span class="nx">msg</span> <span class="o">=</span> <span class="s1">&#39;Undefined module &#39;</span> <span class="o">+</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39; skipped&#39;</span><span class="p">;</span>
                    <span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">msg</span><span class="p">,</span> <span class="s1">&#39;warn&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>
                    <span class="c1">// self.inserted[s[i]] = true;</span>
                    <span class="nx">self</span><span class="p">.</span><span class="nx">skipped</span><span class="p">[</span><span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">true</span><span class="p">;</span>
                <span class="p">}</span>
                <span class="k">continue</span><span class="p">;</span>

            <span class="p">}</span>

            <span class="nx">group</span> <span class="o">=</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">group</span> <span class="o">&amp;&amp;</span> <span class="nx">self</span><span class="p">.</span><span class="nx">groups</span><span class="p">[</span><span class="nx">m</span><span class="p">.</span><span class="nx">group</span><span class="p">])</span> <span class="o">||</span> <span class="nx">NOT_FOUND</span><span class="p">;</span>

            <span class="c1">// The load type is stored to offer the possibility to load</span>
            <span class="c1">// the css separately from the script.</span>
            <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">type</span> <span class="o">||</span> <span class="nx">type</span> <span class="o">===</span> <span class="nx">m</span><span class="p">.</span><span class="nx">type</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">self</span><span class="p">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">];</span>
<span class="nx">Y</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;attempting to load &#39;</span> <span class="o">+</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">]</span> <span class="o">+</span> <span class="s1">&#39;, &#39;</span> <span class="o">+</span> <span class="nx">self</span><span class="p">.</span><span class="nx">base</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">,</span> <span class="s1">&#39;loader&#39;</span><span class="p">);</span>

                <span class="k">if</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">type</span> <span class="o">===</span> <span class="nx">CSS</span><span class="p">)</span> <span class="p">{</span>
                    <span class="nx">fn</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Get</span><span class="p">.</span><span class="nx">css</span><span class="p">;</span>
                    <span class="nx">attr</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">cssAttributes</span><span class="p">;</span>
                <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                    <span class="nx">fn</span> <span class="o">=</span> <span class="nx">Y</span><span class="p">.</span><span class="nx">Get</span><span class="p">.</span><span class="nx">script</span><span class="p">;</span>
                    <span class="nx">attr</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">jsAttributes</span><span class="p">;</span>
                <span class="p">}</span>

                <span class="nx">url</span> <span class="o">=</span> <span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">fullpath</span><span class="p">)</span> <span class="o">?</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_filter</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">fullpath</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">])</span> <span class="o">:</span>
                      <span class="nx">self</span><span class="p">.</span><span class="nx">_url</span><span class="p">(</span><span class="nx">m</span><span class="p">.</span><span class="nx">path</span><span class="p">,</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span> <span class="nx">group</span><span class="p">.</span><span class="nx">base</span> <span class="o">||</span> <span class="nx">m</span><span class="p">.</span><span class="nx">base</span><span class="p">);</span>

                <span class="nx">fn</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span> <span class="p">{</span>
                    <span class="nx">data</span><span class="o">:</span> <span class="nx">s</span><span class="p">[</span><span class="nx">i</span><span class="p">],</span>
                    <span class="nx">onSuccess</span><span class="o">:</span> <span class="nx">handleSuccess</span><span class="p">,</span>
                    <span class="nx">insertBefore</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">,</span>
                    <span class="nx">charset</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">charset</span><span class="p">,</span>
                    <span class="nx">attributes</span><span class="o">:</span> <span class="nx">attr</span><span class="p">,</span>
                    <span class="nx">onFailure</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_onFailure</span><span class="p">,</span>
                    <span class="nx">onTimeout</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_onTimeout</span><span class="p">,</span>
                    <span class="nx">timeout</span><span class="o">:</span> <span class="nx">self</span><span class="p">.</span><span class="nx">timeout</span><span class="p">,</span>
                    <span class="nx">autopurge</span><span class="o">:</span> <span class="kc">false</span><span class="p">,</span>
                    <span class="nx">context</span><span class="o">:</span> <span class="nx">self</span>
                <span class="p">});</span>

                <span class="k">return</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// we are finished</span>
        <span class="nx">self</span><span class="p">.</span><span class="nx">_loading</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>

        <span class="nx">fn</span> <span class="o">=</span> <span class="nx">self</span><span class="p">.</span><span class="nx">_internalCallback</span><span class="p">;</span>

        <span class="c1">// internal callback for loading css first</span>
        <span class="k">if</span> <span class="p">(</span><span class="nx">fn</span><span class="p">)</span> <span class="p">{</span>
            <span class="c1">// Y.log(&#39;loader internal&#39;);</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">_internalCallback</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
            <span class="nx">fn</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">self</span><span class="p">);</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="c1">// Y.log(&#39;loader complete&#39;);</span>
            <span class="nx">self</span><span class="p">.</span><span class="nx">_onSuccess</span><span class="p">();</span>
        <span class="p">}</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Apply filter defined for this instance to a url/path</span>
<span class="cm">     * method _filter</span>
<span class="cm">     * @param {string} u the string to filter.</span>
<span class="cm">     * @param {string} name the name of the module, if we are processing</span>
<span class="cm">     * a single module as opposed to a combined url.</span>
<span class="cm">     * @return {string} the filtered string.</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_filter</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">u</span><span class="p">,</span> <span class="nx">name</span><span class="p">)</span> <span class="p">{</span>
        <span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">filter</span><span class="p">,</span>
            <span class="nx">hasFilter</span> <span class="o">=</span> <span class="nx">name</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="nx">name</span> <span class="k">in</span> <span class="k">this</span><span class="p">.</span><span class="nx">filters</span><span class="p">),</span>
            <span class="nx">modFilter</span> <span class="o">=</span> <span class="nx">hasFilter</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">filters</span><span class="p">[</span><span class="nx">name</span><span class="p">];</span>

        <span class="k">if</span> <span class="p">(</span><span class="nx">u</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">hasFilter</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">f</span> <span class="o">=</span> <span class="p">(</span><span class="nx">L</span><span class="p">.</span><span class="nx">isString</span><span class="p">(</span><span class="nx">modFilter</span><span class="p">))</span> <span class="o">?</span>
                    <span class="k">this</span><span class="p">.</span><span class="nx">FILTER_DEFS</span><span class="p">[</span><span class="nx">modFilter</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">()]</span> <span class="o">||</span> <span class="kc">null</span> <span class="o">:</span>
                    <span class="nx">modFilter</span><span class="p">;</span>
            <span class="p">}</span>
            <span class="k">if</span> <span class="p">(</span><span class="nx">f</span><span class="p">)</span> <span class="p">{</span>
                <span class="nx">u</span> <span class="o">=</span> <span class="nx">u</span><span class="p">.</span><span class="nx">replace</span><span class="p">(</span><span class="k">new</span> <span class="nb">RegExp</span><span class="p">(</span><span class="nx">f</span><span class="p">.</span><span class="nx">searchExp</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">),</span> <span class="nx">f</span><span class="p">.</span><span class="nx">replaceStr</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="k">return</span> <span class="nx">u</span><span class="p">;</span>
    <span class="p">},</span>

    <span class="cm">/**</span>
<span class="cm">     * Generates the full url for a module</span>
<span class="cm">     * method _url</span>
<span class="cm">     * @param {string} path the path fragment.</span>
<span class="cm">     * @return {string} the full url.</span>
<span class="cm">     * @private</span>
<span class="cm">     */</span>
    <span class="nx">_url</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">path</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="nx">base</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">_filter</span><span class="p">((</span><span class="nx">base</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">base</span> <span class="o">||</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="nx">path</span><span class="p">,</span> <span class="nx">name</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">};</span>
</pre></div>

                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div id="moduleList" class="module">
                        <h4>Modules</h4>
                        <ul class="content">
                                <li class=""><a href="module_align-plugin.html" title="align-plugin">align-plugin</a></li>
                                <li class=""><a href="module_anim.html" title="anim">anim</a></li>
                                <li class=""><a href="module_arraysort.html" title="arraysort">arraysort</a></li>
                                <li class=""><a href="module_async-queue.html" title="async-queue">async-queue</a></li>
                                <li class=""><a href="module_attribute.html" title="attribute">attribute</a></li>
                                <li class=""><a href="module_autocomplete.html" title="autocomplete">autocomplete</a></li>
                                <li class=""><a href="module_base.html" title="base">base</a></li>
                                <li class=""><a href="module_cache.html" title="cache">cache</a></li>
                                <li class=""><a href="module_charts.html" title="charts">charts</a></li>
                                <li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li>
                                <li class=""><a href="module_collection.html" title="collection">collection</a></li>
                                <li class=""><a href="module_console.html" title="console">console</a></li>
                                <li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li>
                                <li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
                                <li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li>
                                <li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
                                <li class=""><a href="module_datatable.html" title="datatable">datatable</a></li>
                                <li class=""><a href="module_datatype.html" title="datatype">datatype</a></li>
                                <li class=""><a href="module_dd.html" title="dd">dd</a></li>
                                <li class=""><a href="module_dial.html" title="dial">dial</a></li>
                                <li class=""><a href="module_dom.html" title="dom">dom</a></li>
                                <li class=""><a href="module_dump.html" title="dump">dump</a></li>
                                <li class=""><a href="module_editor.html" title="editor">editor</a></li>
                                <li class=""><a href="module_escape.html" title="escape">escape</a></li>
                                <li class=""><a href="module_event.html" title="event">event</a></li>
                                <li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li>
                                <li class=""><a href="module_event-gestures.html" title="event-gestures">event-gestures</a></li>
                                <li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
                                <li class=""><a href="module_event-touch.html" title="event-touch">event-touch</a></li>
                                <li class=""><a href="module_event-valuechange.html" title="event-valuechange">event-valuechange</a></li>
                                <li class=""><a href="module_highlight.html" title="highlight">highlight</a></li>
                                <li class=""><a href="module_history.html" title="history">history</a></li>
                                <li class=""><a href="module_history-deprecated.html" title="history-deprecated">history-deprecated</a></li>
                                <li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
                                <li class=""><a href="module_intl.html" title="intl">intl</a></li>
                                <li class=""><a href="module_io.html" title="io">io</a></li>
                                <li class=""><a href="module_json.html" title="json">json</a></li>
                                <li class=""><a href="module_jsonp.html" title="jsonp">jsonp</a></li>
                                <li class="selected"><a href="module_loader.html" title="loader">loader</a></li>
                                <li class=""><a href="module_node.html" title="node">node</a></li>
                                <li class=""><a href="module_node-flick.html" title="node-flick">node-flick</a></li>
                                <li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li>
                                <li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li>
                                <li class=""><a href="module_oop.html" title="oop">oop</a></li>
                                <li class=""><a href="module_overlay.html" title="overlay">overlay</a></li>
                                <li class=""><a href="module_plugin.html" title="plugin">plugin</a></li>
                                <li class=""><a href="module_pluginhost.html" title="pluginhost">pluginhost</a></li>
                                <li class=""><a href="module_pluginhost-base.html" title="pluginhost-base">pluginhost-base</a></li>
                                <li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
                                <li class=""><a href="module_querystring.html" title="querystring">querystring</a></li>
                                <li class=""><a href="module_queue-promote.html" title="queue-promote">queue-promote</a></li>
                                <li class=""><a href="module_recordset.html" title="recordset">recordset</a></li>
                                <li class=""><a href="module_resize.html" title="resize">resize</a></li>
                                <li class=""><a href="module_scrollview.html" title="scrollview">scrollview</a></li>
                                <li class=""><a href="module_scrollview-base.html" title="scrollview-base">scrollview-base</a></li>
                                <li class=""><a href="module_scrollview-base-ie.html" title="scrollview-base-ie">scrollview-base-ie</a></li>
                                <li class=""><a href="module_scrollview-paginator.html" title="scrollview-paginator">scrollview-paginator</a></li>
                                <li class=""><a href="module_scrollview-scrollbars.html" title="scrollview-scrollbars">scrollview-scrollbars</a></li>
                                <li class=""><a href="module_shim-plugin.html" title="shim-plugin">shim-plugin</a></li>
                                <li class=""><a href="module_slider.html" title="slider">slider</a></li>
                                <li class=""><a href="module_sortable.html" title="sortable">sortable</a></li>
                                <li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
                                <li class=""><a href="module_substitute.html" title="substitute">substitute</a></li>
                                <li class=""><a href="module_swf.html" title="swf">swf</a></li>
                                <li class=""><a href="module_swfdetect.html" title="swfdetect">swfdetect</a></li>
                                <li class=""><a href="module_tabview.html" title="tabview">tabview</a></li>
                                <li class=""><a href="module_test.html" title="test">test</a></li>
                                <li class=""><a href="module_text.html" title="text">text</a></li>
                                <li class=""><a href="module_transition.html" title="transition">transition</a></li>
                                <li class=""><a href="module_uploader.html" title="uploader">uploader</a></li>
                                <li class=""><a href="module_widget.html" title="widget">widget</a></li>
                                <li class=""><a href="module_widget-anim.html" title="widget-anim">widget-anim</a></li>
                                <li class=""><a href="module_widget-base-ie.html" title="widget-base-ie">widget-base-ie</a></li>
                                <li class=""><a href="module_widget-child.html" title="widget-child">widget-child</a></li>
                                <li class=""><a href="module_widget-locale.html" title="widget-locale">widget-locale</a></li>
                                <li class=""><a href="module_widget-parent.html" title="widget-parent">widget-parent</a></li>
                                <li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li>
                                <li class=""><a href="module_widget-position-align.html" title="widget-position-align">widget-position-align</a></li>
                                <li class=""><a href="module_widget-position-constrain.html" title="widget-position-constrain">widget-position-constrain</a></li>
                                <li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li>
                                <li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li>
                                <li class=""><a href="module_yql.html" title="yql">yql</a></li>
                                <li class=""><a href="module_yui.html" title="yui">yui</a></li>
                        </ul>
                    </div>

                    <div id="classList" class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="Loader.html" title="Loader">Loader</a></li>
                        </ul>
                    </div>

                    <div id="fileList" class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class="selected"><a href="loader.js.html" title="loader.js">loader.js</a></li>
                                <li class=""><a href="meta.js.html" title="meta.js">meta.js</a></li>
                                <li class=""><a href="rollup.js.html" title="rollup.js">rollup.js</a></li>
                                <li class=""><a href="yui3.js.html" title="yui3.js">yui3.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2011 Yahoo! Inc. All rights reserved.
	</div>
</div>
<script type="text/javascript">

    var ALL_YUI_PROPS = [{"access": "", "host": "Loader", "name": "addGroup", "url": "Loader.html#method_addGroup", "type": "method"}, {"access": "", "host": "Loader", "name": "addModule", "url": "Loader.html#method_addModule", "type": "method"}, {"access": "private", "host": "Loader", "name": "_addSkin", "url": "Loader.html#method__addSkin", "type": "method"}, {"access": "", "host": "Loader", "name": "allowRollup", "url": "Loader.html#property_allowRollup", "type": "property"}, {"access": "", "host": "Loader", "name": "base", "url": "Loader.html#property_base", "type": "property"}, {"access": "", "host": "Loader", "name": "calculate", "url": "Loader.html#method_calculate", "type": "method"}, {"access": "", "host": "Loader", "name": "charset", "url": "Loader.html#property_charset", "type": "property"}, {"access": "", "host": "Loader", "name": "combine", "url": "Loader.html#property_combine", "type": "property"}, {"access": "", "host": "Loader", "name": "comboBase", "url": "Loader.html#property_comboBase", "type": "property"}, {"access": "", "host": "Loader", "name": "context", "url": "Loader.html#property_context", "type": "property"}, {"access": "", "host": "Loader", "name": "cssAttributes", "url": "Loader.html#property_cssAttributes", "type": "property"}, {"access": "", "host": "Loader", "name": "data", "url": "Loader.html#property_data", "type": "property"}, {"access": "", "host": "Loader", "name": "dirty", "url": "Loader.html#property_dirty", "type": "property"}, {"access": "private", "host": "Loader", "name": "_explode", "url": "Loader.html#method__explode", "type": "method"}, {"access": "", "host": "Loader", "name": "filter", "url": "Loader.html#property_filter", "type": "property"}, {"access": "private", "host": "Loader", "name": "_filter", "url": "Loader.html#method__filter", "type": "method"}, {"access": "", "host": "Loader", "name": "filters", "url": "Loader.html#property_filters", "type": "property"}, {"access": "", "host": "Loader", "name": "force", "url": "Loader.html#property_force", "type": "property"}, {"access": "", "host": "Loader", "name": "formatSkin", "url": "Loader.html#method_formatSkin", "type": "method"}, {"access": "", "host": "Loader", "name": "getLangPackName", "url": "Loader.html#method_getLangPackName", "type": "method"}, {"access": "", "host": "Loader", "name": "getProvides", "url": "Loader.html#method_getProvides", "type": "method"}, {"access": "", "host": "Loader", "name": "getRequires", "url": "Loader.html#method_getRequires", "type": "method"}, {"access": "", "host": "Loader", "name": "ignore", "url": "Loader.html#property_ignore", "type": "property"}, {"access": "", "host": "Loader", "name": "ignoreRegistered", "url": "Loader.html#property_ignoreRegistered", "type": "property"}, {"access": "", "host": "Loader", "name": "insert", "url": "Loader.html#method_insert", "type": "method"}, {"access": "", "host": "Loader", "name": "insertBefore", "url": "Loader.html#property_insertBefore", "type": "property"}, {"access": "", "host": "Loader", "name": "inserted", "url": "Loader.html#property_inserted", "type": "property"}, {"access": "private", "host": "Loader", "name": "_internalCallback", "url": "Loader.html#property__internalCallback", "type": "property"}, {"access": "", "host": "Loader", "name": "jsAttributes", "url": "Loader.html#property_jsAttributes", "type": "property"}, {"access": "", "host": "Loader", "name": "loaded", "url": "Loader.html#property_loaded", "type": "property"}, {"access": "", "host": "Loader", "name": "loadNext", "url": "Loader.html#method_loadNext", "type": "method"}, {"access": "", "host": "Loader", "name": "loadOptional", "url": "Loader.html#property_loadOptional", "type": "property"}, {"access": "", "host": "Loader", "name": "maxURLLength", "url": "Loader.html#property_maxURLLength", "type": "property"}, {"access": "", "host": "Loader", "name": "moduleInfo", "url": "Loader.html#property_moduleInfo", "type": "property"}, {"access": "", "host": "Loader", "name": "onCSS", "url": "Loader.html#method_onCSS", "type": "method"}, {"access": "", "host": "Loader", "name": "onFailure", "url": "Loader.html#method_onFailure", "type": "method"}, {"access": "", "host": "Loader", "name": "onProgress", "url": "Loader.html#method_onProgress", "type": "method"}, {"access": "", "host": "Loader", "name": "onSuccess", "url": "Loader.html#method_onSuccess", "type": "method"}, {"access": "", "host": "Loader", "name": "onTimeout", "url": "Loader.html#method_onTimeout", "type": "method"}, {"access": "", "host": "Loader", "name": "patterns", "url": "Loader.html#property_patterns", "type": "property"}, {"access": "private", "host": "Loader", "name": "_reduce", "url": "Loader.html#method__reduce", "type": "method"}, {"access": "", "host": "Loader", "name": "require", "url": "Loader.html#method_require", "type": "method"}, {"access": "", "host": "Loader", "name": "required", "url": "Loader.html#property_required", "type": "property"}, {"access": "private", "host": "Loader", "name": "_rollup", "url": "Loader.html#method__rollup", "type": "method"}, {"access": "", "host": "Loader", "name": "rollups", "url": "Loader.html#property_rollups", "type": "property"}, {"access": "", "host": "Loader", "name": "root", "url": "Loader.html#property_root", "type": "property"}, {"access": "private", "host": "Loader", "name": "_setup", "url": "Loader.html#method__setup", "type": "method"}, {"access": "", "host": "Loader", "name": "skin", "url": "Loader.html#property_skin", "type": "property"}, {"access": "", "host": "Loader", "name": "skipped", "url": "Loader.html#property_skipped", "type": "property"}, {"access": "private", "host": "Loader", "name": "_sort", "url": "Loader.html#method__sort", "type": "method"}, {"access": "", "host": "Loader", "name": "sorted", "url": "Loader.html#property_sorted", "type": "property"}, {"access": "", "host": "Loader", "name": "timeout", "url": "Loader.html#property_timeout", "type": "property"}, {"access": "private", "host": "Loader", "name": "_url", "url": "Loader.html#method__url", "type": "method"}];
</script>
</body>
</html>
